Visual Studio C ++项目的目标文件位置 [英] Object file location of Visual Studio C++ project

查看:135
本文介绍了Visual Studio C ++项目的目标文件位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,源代码文件的目录结构与名称空间链接在一起.例如,将在文件中实现属于名称空间MyNamespace_A的类Util. .../MyNamespace_A/Util.cpp

In our project, the directory structure of our source code files are linked with our namespaces. E.g., a class Util which belongs to the namespace MyNamespace_A would be implemented in the file .../MyNamespace_A/Util.cpp

现在,名称空间"OtherNamespace :: SubNamespace"也应该具有Util类.应该在文件中实现 .../OtherNamespace/SubNamespace/Util.cpp

Now, the namespace 'OtherNamespace::SubNamespace' should also have a Util class. It should be implemented in the file .../OtherNamespace/SubNamespace/Util.cpp

不指定显式目标文件(.cpp文件的属性-> C/C ++->输出文件->目标文件名),这将导致问题,因为两个目标文件将具有相同的名称,默认情况下,它们存储在同一目录中(即"$(IntDir)").

Without specifying an explicit object file (Properties of the .cpp file -> C/C++ -> Output Files -> Object File Name) this will lead to problems because two object files will have the same name and by default, they are stored in the same directory (which is '$(IntDir)').

是否有一种自动机制可以让我指定输出文件的目录结构应与源代码目录的结构相同? 除了为每个源代码文件指定目标文件名之外,我还可以通过其他方式解决该问题吗?

Is there an automatic mechanism which lets me specify that the directory structure of the output files shall be the same as the structure of the source code directories? Can I solve the problem in a different way than specifying the object file name for each of my source code files?

推荐答案

右键单击项目,然后转到...

Right-click on project and go to...

属性-> C/C ++->输出文件->输出文件名

Properties -> C/C++ -> Output Files -> Output File Name

然后输入...

$(IntDir)/%(RelativeDir)/

$(IntDir)/%(RelativeDir)/

这会将每个.obj文件放入源文件中的子文件夹中.

This will place every .obj file into a subfolder as in the source files.

这篇关于Visual Studio C ++项目的目标文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆