Visual Studio 2010 & 2008 can't handle source files with identical names in different folders?
So @Hans Passant pointed in the right direction, Thanks!! You don't have to list the file, a folder is sufficient. Then if you look in the defined macros at the bottom of the VS 2010 list, you'll see:
%(RelativeDir)/ Univariate/
The problem, as posted, was actually a simplified version of what I'm working on -- a couple of levels of folders in a single project and there are a couple of name conflicts. Hence, I really wanted someway to just "fix" it...
If you right click on the project in the solution explorer, choose C/C++ -> "Output Files" and type the following into the "Object File Name" box:
$(IntDir)/%(RelativeDir)/
Note that I also selected (All Configurations, All Platforms) from the drop downs. This will compile every file in a directory hierarchy which mirrors the source tree. VS2010 will begin the build by creating these directories if they don't exist. Further, for those who hate white space in their directory names, this macro does remove all spaces, so there is no need to play around with double quotes when using it.
This is exactly what I wanted -- identical to the way my Makefiles work on the Ubuntu side, while still keeping the source tree clean.
This is easy to fix in the IDE. Click the first file in the folder, Shift+Click the last file so all of them are selected. Right-click, Properties, C++, Output Files. Change the Object File Name from $(IntDir)\
to, say, $(IntDir)\Univariate\
. You can repeat for the Multivariate file group although that's not strictly necessary.
You're right, VS can't handle that, and never could. The root problem is that it generates a .obj
file for each .cpp
file in the project, and they're all placed in the same folder. So you end up with multiple .cpp
files compiling to Adaptive.obj
in your case, for example.
At least the linker generates a warning for it now. That wasn't always the case.
You should be able to work around this by ensuring the files use different Intermediate Directory paths, but it is a bit of a hack around something that ought to be possible.
Of course, you could always file a bug report or feature request on it on Microsoft Connect