JohnQQ
JohnQQ

Reputation: 55

Object file location of Visual Studio C++ project

In our project, the directory structure of our source code files are linked with our namespaces. E.g., a class Util which belongs to the namespace MyNamespace_A would be implemented in the file .../MyNamespace_A/Util.cpp

Now, the namespace 'OtherNamespace::SubNamespace' should also have a Util class. It should be implemented in the file .../OtherNamespace/SubNamespace/Util.cpp

Without specifying an explicit object file (Properties of the .cpp file -> C/C++ -> Output Files -> Object File Name) this will lead to problems because two object files will have the same name and by default, they are stored in the same directory (which is '$(IntDir)').

Is there an automatic mechanism which lets me specify that the directory structure of the output files shall be the same as the structure of the source code directories? Can I solve the problem in a different way than specifying the object file name for each of my source code files?

Upvotes: 3

Views: 4481

Answers (1)

dspfnder
dspfnder

Reputation: 1123

Right-click on project and go to...

Properties -> C/C++ -> Output Files -> Output File Name

Then enter...

$(IntDir)/%(RelativeDir)/

This will place every .obj file into a subfolder as in the source files.

Upvotes: 7

Related Questions