[Visual C++] *.obj creation folder

Started by
1 comment, last by maxest 8 years, 2 months ago

Visual C++ creates all *.obj files in Debug or Release folders. Is there a way to make it create those files next to their corresponding *.cpp files? Because at the moment when I have two files with the same names but in different folders in my directory hierarchy I get conflicts.

Advertisement

What I do to get around this is have VC++ makes all of the sub directories in the object folders.

In the Project Property Pages -> C/C++ -> Output Files

Object File Name = $(IntDir)%(RelativeDir)\

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Good hint with the %(RelativeDir). Although your solution creates all the files in wrong directory for me.

My folders structure is this:


build -> vc2013 -> here lie project and solution files as well as Debug and Release folders
src -> here are all sources

So when I use your solution my relative src files have paths:


../../src/file.cpp

And as such my src objs are generated next to vc2013 folder, that is, two folders up from the $(IntDir) (which is correct because %(RelativeDir) has two "..").

To solve this problem and have my objs in nice tree structure (just like src files are) but *inside* $(IntDir) (that is, either Debug or Release) I did this:


$(IntDir)\dummy\dummy\%(RelativeDir)\

The dummy folders don't exist and they don't have to because the part ..\..\ that is part of %(RelativeDir) will cancel them.

This topic is closed to new replies.

Advertisement