两个相同名称的文件在Visual Studio中给出链接器错误(Two files of the same name give linker error in Visual Studio [dupli

编程入门 行业动态 更新时间:2024-10-20 00:48:19
两个相同名称的文件在Visual Studio中给出链接器错误(Two files of the same name give linker error in Visual Studio [duplicate])

我正在使用Visual Studio 2010编译我的C ++项目,并且链接器正在浏览两个具有相同名称的文件 - 但它们位于完全不同的目录中。 如何让链接器识别它们是不同的文件?

This question already has an answer here:

VisualStudio project with multiple sourcefiles of the same name? 2 answers

I'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 files

I'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.

更多推荐

本文发布于:2023-08-05 07:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428891.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   名称   两个   链接   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!