Boost logo

Boost-Build :

From: Felix E. Klee (felix.klee.jamboost_at_[hidden])
Date: 2003-01-30 08:58:11


I'm in the process of converting a project to Boost Build V2. However, one
problem is that Boost Build puts all the object files in the same directory
even if the sources are in different directories. Consider eg. a project
consisting of three files, two of which are named identically:

void a_bar();
void b_bar();
int main() {
return 0;
#include <iostream>
void a_bar() { std::cout << "a_bar\n"; }
#include <iostream>
void b_bar() { std::cout << "b_bar\n"; }

Bjam compiles this just fine but the compilation command for b/bar.cpp
overwrites object file created from a/bar.cpp and when linking I get a
corresponding error message. Here are several solutions that came into my
1. Purposely call the files a/bar.cpp and b/bar.cpp different, eg.
a/bar_1.cpp and b/bar_2.cpp. I don't like this solution, however, since it
is somewhat ugly. To be consistent and to avoid future problems one might
consider eg. appending a random eight digit number to *each* file name.
2. Flatten out the directory structure, ie. the project should occupy only
one directory. Files would be named foo.cpp, a_bar.cpp, and b_bar.cpp.
This is the solution that I like least since in the original project I will
get to many files in one directory and their names will be extremely long.
There was a reason that I used directories in the first place!
3. Compile each directory into a library. This is the best solution I can
think of but it will result in heaps of libraries when applied to the
original project.

BTW, my directory structure mirrors the namespace structure and the structure
of nested classes. Maybe a solution where the sources for nested classes are
kept in the same directory as their containing classes but different
namespaces are put in different directories is the best. This would be a
compromise between solution 2 and 3.

What do you recommend? Or do you think that Boost Build is the culprit since
it doesn't preserve the directory structure?


To contact me personally don't reply but send email to 
felix DOT klee AT inka DOT de

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at