Boost logo

Boost-Build :

From: Ulrich Eckhardt (gclbb-jamboost_at_[hidden])
Date: 2003-08-24 07:52:32


Greetings!

I'm trying to build an existing project which uses a few other libs. To
some extent it works, but I'm not confident that the result and the way to
it are good.

I'm using three external lib: boost_thread, SDL and SDL_net. They all
require different steps to compile and link. For the sake of simplicity I
have split these up in this post, I hope that doesn't change anything.

1. boost_thread: for this one, I have only yet found a solution for
compiling, for linking I still have to select the proper version by hand
and add that to the linkflags:

exe foo
: # sources
foo.cpp
: # requirements
<include>$(BOOST_ROOT)
<find-library>boost_thread
# (added linebreaks for readability)
<linkflags>-L../boost-1.30.2/libs/thread/build/bin/
libboost_thread.so/gcc-3.2/debug/runtime-link-dynamic/
shared-linkable-true/threading-multi/
;

Two things here: I wonder if the use of BOOST_ROOT is right here. That
variable is used by the build-system to find its components but not
necessarily to find the boost-sources. Imagine, in theory, you could use
the build-system of one boost to compile and link a program that uses a
different version. (Yes, I know that this is very philosophical and it
also doesn't really concern me ATM).

The second thing is the 'hard-coded' path to the library. This will break
for other users, or even for me should I decide to change from debug to
release. Using separate '<debug><linkflags>-L...' and
'<release><linkflags>-L...' is not really an alternative.

What I would like to do in that case is to tell the buildsystem "you find a
Jamfile for the boost_thread lib/dll at $(BOOST_ROOT)/libs/thread/, link
this executable with the right version of it".

2. SDL: SDL generates a script at install-time that can be called with
different arguments to get the right flags for compiling other programs
with it.

The first (and working) approach was to use it directly:
...
: # requirements
<cxxflags>"`sdl-config --cflags`"
<linkflags>"`sdl-config --libs`"
But this approach calls the script at every invokation of the compiler,
which is unnecessary. Also I'm not sure about the portability of using
backticks (`) outside of bash.

Therefore, and to give %USER% a bit more choice, I thought to do this:

SDL_CXXFLAGS ?= "`sdl-config --cflags`" ;
...
: # requirements
<cxxflags>$(SDL_CXXFLAGS)

This also works, but still invokes the script every time the compiler is
invoked. Therefore:

rule sdl-config-cflags
{
ECHO "inside rule sdl-config-cflags" ;
return [ Run sdl-config --cflags ] ;
}
SDL_CXXFLAGS ?= [ sdl-config-cflags ] ;

However, there I probably have a problem understanding the way jam or boost
build works, because I do see that the rule is called (or should I say
invoked ?), it even prints the echo twice (I wonder why) but the 'Run ...'
is not evaluated. It even seems that the Run-call gets totally ignored,
even if I call it with a program that doesn't exist or one that starts a
GUI nothing changes !?

3. SDL_net: this one should only require the compile-flags of SDL (is there
a sensible way to define that dependency here?) and the additional lib
called SDL_net which I added to the requirements using
<find-library>SDL_net
This works, I just wonder if that is The Right Way(tm).

Lastly, I wonder if there is a FAQ or something like that. I can't imagine
my problems are so special that they werent solved already.

thank you for your help,
Ulrich Eckhardt

 


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