Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-01-30 10:34:11


Hi Felix

Felix E. Klee wrote:
> Hi,
>
> 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.

[...]

> 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
> mind:
> 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.

Ick, that's surely not attractive at all.

> 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!

Right.

> 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.

I'd agree that this is the best solution.

> 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.

Are you getting name conflicts between identically named classes in different
namespaces? Then I think the best idea would be to make a librarary for each
namespace.

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

Heh... Boost.Build is certainly wrong here. It should, at least, to issue a
big warning message when two files are compiled to the same location.

As to the "right" solution. Historically, Boost.Build is used to construct a
collection of libraries, each of them is placed in a separate directory, with
unqiue names of source files. Generally, I think it's a good idea to keep one
Jamfile <-> one sourcedir relationship, which mean creating a library for each
directory. However, I'm not sure we're at liberty to establish that requirement.

- Volodya

 


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk