我正在使用Visual Studio 2010编译我的C ++项目,并且链接器正在浏览两个具有相同名称的文件 - 但它们位于完全不同的目录中。 如何让链接器识别它们是不同的文件?
This question already has an answer here:
VisualStudio project with multiple sourcefiles of the same name? 2 answersI'm using Visual Studio 2010 to compile my C++ project, and the linker is barfing on two of my files which have the same name- but they're in completely different directories. How can I make the linker recognize that they are different files?
最满意答案
我相信问题来自于以下事实:所有.obj文件都写入同一个文件夹,因此编译这两个源文件的输出会发生冲突。 我认为至少有两种可能的解决方案:
1)为每个输入文件夹使用不同的输出目录(构建目录)2)为每个(或只有一个)源文件创建自定义对象文件名
我不确定第一个选项,但是对于第二个选项,您应该能够右键单击解决方案资源管理器中的源文件,选择“属性”,并找到一些配置设置以覆盖输出(.obj )为该源文件创建的文件。
I believe the problem comes from the fact that all your .obj files are written to the same folder, and so the outputs from compiling those two source files are colliding. I think there are at least two possible solutions:
Use a different output directory (build directory) for each input folder Create custom object file names for each (or just one) of your source filesI'm not certain about the first option, but for the second, you should be able to right-click the source file in the solution explorer, select "Properties", and find some configuration setting to over-ride the output (.obj) file created for that source file.
更多推荐
发布评论