[ACCEPTED]-Two files of the same name give linker error in Visual Studio-visual-studio-2010

Accepted answer
Score: 15

I believe the problem comes from the fact 10 that all your .obj files are written to 9 the same folder, and so the outputs from 8 compiling those two source files are colliding. I 7 think there are at least two possible solutions:

  1. Use a different output directory (build directory) for each input folder
  2. Create custom object file names for each (or just one) of your source files

I'm 6 not certain about the first option, but 5 for the second, you should be able to right-click 4 the source file in the solution explorer, select 3 "Properties", and find some configuration 2 setting to over-ride the output (.obj) file 1 created for that source file.

Score: 9

Use $(IntDir)%(RelativeDir) in "Object File Name" property 3

(Configuration Properties -> C/C++ -> Output 2 Files -> Object File Name)

  • of project, OR
  • of .cpp file.

This is an 1 answer from the related question VisualStudio project with multiple sourcefiles of the same name?.

More Related questions