Boost logo

Boost-Build :

From: Christopher Currie (Christopher_at_[hidden])
Date: 2003-07-29 14:07:33


Ok, now that I have my usage-dependencies cascading properly, all my
libraries are building like I expect. However, I'm now encountering a
problem where the libraries aren't being ordered properly on the link
line. An example Jamfile:

# Jamfile.v2
lib libcommon
: common.cpp
;

lib libmanager
: manager.cpp
: <dependency>libsub1
<dependency>libsub2
:
: <library>libsub1
<library>libsub2
;

lib libsub1
: sub1.cpp
: <dependency>libcommon
:
: <library>libcommon
;

lib libsub2
: sub2.cpp
: <dependency>libcommon
:
: <library>libcommon
;

exe app
: main.cpp
libmanager
: <link>static
;

Here we have an application that uses a central manager library, that
depends on two helper libraries, that both depend on some common code
library. All the libs build fine, but the linker is given something like
the following (paths removed for clarity):

CC -g -o app main.o libmanager.a libcommon.a libsub1.a libsub2.a

As you can see, the common library appears *before* the helper
libraries, which means that the symbols they depend on don't get linked
in. The rules don't ensure that dependent libraries occur before their
dependencies.

The GCC toolset gets around this problem by listing every library twice.
This is fine for static libraries, but the Sun compiler complains if you
attempt to link the same shared library twice in an application.

I've tried to trace how the library list gets built, but I'm not sure I
understand it. It seems to simply assemble the usage-dependencies
together without regard to the dependencies between the targets; this
gets back to my earlier post asking if the <library> directive should
have some implicit <dependency> semantics.

Thanks for listening,
Christopher

 


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