Boost logo

Boost-Build :

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


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
: # requirements
# (added linebreaks for readability)

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

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
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, david.abrahams at, gregod at, cpdaniel at, john at