Boost logo

Boost-Build :

From: Philipp Frauenfelder (pfrauenf_at_[hidden])
Date: 2004-07-06 04:27:13


[ I have not been able to search the list archives as Yahoo! is
temporarly refusing to create accounts. ]

Dear Jamboosters

I am using Boost.Build v2 in one of my own projects (switching
from ugly Makefile hacks which were terribly slow). It works
great and is much more powerful and faster than make with
respect to dependencies (implicit and explicit) without much
programming, great, thanks a lot! I want to use external
libraries in my project and have two questions regarding this. I
am using Debian GNU/Linux and I am a complete newbie in the Jam
/ Boost.Build world.

- Libraries (also the internal ones) are linked twice to my
executables.

This is my master Jamfile:
----8<----8<----8<----8<----8<----8<----8<----
project concepts-2
: usage-requirements <include>.
: requirements <hardcode-dll-paths>true <variant>debug:<define>DEBUG
: build-dir builds ;

build-project basics ;
----8<----8<----8<----8<----8<----8<----8<----

The Jamfile in basics looks like this:
----8<----8<----8<----8<----8<----8<----8<----
project concepts-2/basics ;

SOURCES = debug.cc fortranException.cc outputOperator.cc ;

lib libconceptsbasics : $(SOURCES) ;
----8<----8<----8<----8<----8<----8<----8<----

And in basics/testsuite, I have some test programs for basics:
----8<----8<----8<----8<----8<----8<----8<----
project concepts-2/basics/testsuite
: requirements <library>/concepts-2/basics//libconceptsbasics ;

unit-test debugTest : debugTest.cc ;
----8<----8<----8<----8<----8<----8<----8<----

When running 'bjam -d2' in basics/testsuite, debugTest.cc is
compiled and linked. The compile step is ok, but the link step
looks like this:
----8<----8<----8<----8<----8<----8<----8<----
gcc.link ../../builds/basics/testsuite/debugTest.test/gcc/debug/debugTest

g++ -g -Wl,-R -Wl,"/scratch/pfrauenf/concepts-jam/builds/basics/gcc/debug" -o "../../builds/basics/testsuite/debugTest.test/gcc/debug/debugTest" "../../builds/basics/testsuite/debugTest.test/gcc/debug/debugTest.o" "../../builds/basics/gcc/debug/libconceptsbasics.so" -Wl,-Bdynamic -Wl,-Bstatic "../../builds/basics/gcc/debug/libconceptsbasics.so" -Wl,-Bdynamic -Wl,-Bstatic -Wl,-Bdynamic
----8<----8<----8<----8<----8<----8<----8<----
ie. the library defined in basics is linked twice. At this
stage, it does not do any harm. But I have a external (binary)
library which I would like to include as well. It is also
linked twice to my executables and the linker complains about
all symbols in the external library to be defined twice.

How can I have the linking just once?

- I would like to have one file where all external libraries are
declared. On some other systems, not all libraries are
installed and I would like to have a configuration option in
this same file which can be evaluated in the Jamfiles for
conditional compiles. I guess the file site-config.jam is
intended for this. Most of the stuff, I got to work, but I
think it is a little bit ugly.

This is my site-config.jam:
----8<----8<----8<----8<----8<----8<----8<----
import project ;
project.initialize $(__name__) ;
project site-config ;

lib libfl : : <name>fl ;

rule HAS_PARDISO { return true ; }
lib pardiso : : <name>pardiso32
<search>/scratch/pfrauenf/pardiso_example :
: <include>/scratch/pfrauenf/pardiso_example <define>HAS_PARDISO ;
----8<----8<----8<----8<----8<----8<----8<----

The libfl is no problem, it is installed everywhere (and I do
not intend to have a conditional compile on it. But I would
like to have a conditional compile with pardiso. The above
works if I use the following code in a Jamfile in a source
directory:
----8<----8<----8<----8<----8<----8<----8<----
import site-config ;

if [ site-config.HAS_PARDISO ] = true {
obj pardiso : pardiso.cc : : <use>/site-config//pardiso ;
SOURCES += pardiso ;
LIBS += <library>/site-config//pardiso ;
}
----8<----8<----8<----8<----8<----8<----8<----
However, I suspect there is a simpler way to achieve this.
Could you give me a hint, please?

Thanks a lot in advance.

Regards

-- 
Philipp | work: pfrauenf_at_[hidden] +41 44 632 60 38
Frauenfelder | home: pfrauenf_at_[hidden] +41 44 862 73 14
[PGP] | http://www.math.ethz.ch/~pfrauenf/
Proudly running Debian GNU/Linux. See http://www.debian.org/
 

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