Menu

#26 Bad output directory in a certain situation

Accepted
nobody
None
Medium
Logic
Defect
2013-10-02
2013-10-02
Anonymous
No

Originally created by: florian.sainjeon (code.google.com)
Originally owned by: florian.sainjeon (code.google.com)

________ What steps will reproduce the problem?

Let's say you have the following architecture:
MainApp
|-- Source
|    |--- MainSource1.cpp
|    |--- MainSource2.cpp
|    `--- DependancyFile.cpp
|-- Include
|    |--- MainInclude1.h
|    `--- MainInclude2.h
`-- SecondaryApp      <------------------------- Doing a "make" on this one
    |--- SecondaryApp.makefile
    |--- Source
    |     |--- SecondarySource1.cpp
    |     `--- SecondarySource2.cpp
    `--- Include
         |--- SecondaryInclude1.h
         `--- SecondaryInclude2.h

Now imagine you're building your SecondaryApp and you included the MainSource1.cpp in your solution because you need it. The MainApp doesn't need to be built, hence why there isn't any makefile.

When building SecondaryApp, DependancyFile.d and .o won't be placed in the SecondaryApp/gccDebug directory but in the SecondaryApp/source directory.

________ What is the expected output? What do you see instead?

Have the *.d and *.o files placed in the correct directory (as indicated before)

________ How to fix it?

- Change the Debug/Release Configuration (basically just remove the ../)
- Change the file output and input paths when compiling the file

Example based on my work - Change this:
# Builds the Debug configuration...
.PHONY: Debug
Debug: create_folders ./gccDebug/../source/DependancyFile.o ./gccDebug/source/SecondarySource.o ./gccDebug/source/SecondaryMain.o
    g++ ./gccDebug/../source/DependancyFile.o ./gccDebug/source/SecondarySource.o ./gccDebug/source/SecondaryMain.o  $(Debug_Library_Path) $(Debug_Libraries) -Wl,-rpath,./ -o ../../serveur/gccruntime/SecondaryApp.exe

# Compiles file ../source/DependancyFile.cpp for the Debug configuration...
-include ./gccDebug/../source/DependancyFile.d
./gccDebug/../source/DependancyFile.o: ../source/DependancyFile.cpp
    $(CPP_COMPILER) $(Debug_Preprocessor_Definitions) $(Debug_Compiler_Flags) -c ../source/DependancyFile.cpp $(Debug_Include_Path) -o ./gccDebug/../source/DependancyFile.o
    $(CPP_COMPILER) $(Debug_Preprocessor_Definitions) $(Debug_Compiler_Flags) -MM ../source/DependancyFile.cpp $(Debug_Include_Path) > ./gccDebug/../source/DependancyFile.d

!! ------------ BY THIS ------------ !!

# Builds the Debug configuration...
.PHONY: Debug
Debug: create_folders ./gccDebug/source/DependancyFile.o ./gccDebug/source/SecondarySource.o ./gccDebug/source/SecondaryMain.o
    g++ ./gccDebug/source/DependancyFile.o ./gccDebug/source/SecondarySource.o ./gccDebug/source/SecondaryMain.o  $(Debug_Library_Path) $(Debug_Libraries) -Wl,-rpath,./ -o ../../serveur/gccruntime/SecondaryApp.exe

# Compiles file source/DependancyFile.cpp for the Debug configuration...
-include ./gccDebug/source/DependancyFile.d
./gccDebug/source/DependancyFile.o: ../source/DependancyFile.cpp
    $(CPP_COMPILER) $(Debug_Preprocessor_Definitions) $(Debug_Compiler_Flags) -c ../source/DependancyFile.cpp $(Debug_Include_Path) -o ./gccDebug/source/DependancyFile.o
    $(CPP_COMPILER) $(Debug_Preprocessor_Definitions) $(Debug_Compiler_Flags) -MM ../source/DependancyFile.cpp $(Debug_Include_Path) > ./gccDebug/source/DependancyFile.d

Discussion


Log in to post a comment.

MongoDB Logo MongoDB