Boost logo

Boost-Build :

From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2008-02-09 12:39:45

   Hi Stefan.

> This works, but I wonder if it is the best way to go for me now. The
> problem is that I want to build this project on both OS X and Linux
> and the libraries are in different locations and even have slightly
> different names I think.

   There is no problem with configuring Boost Build to look for
different library names based on different OSs or based on any other
feature for that matter. Here's an example:

lib acessllib_static_rtlStatic : : <name>ACE_SSL <toolset>gcc

                              <search>$(ACE_ROOT)/lib ;
lib acessllib_static_rtlStatic : : <name>ACE_SSLsd <toolset>msvc
   <variant>debug <search>$(ACE_ROOT)/lib ;
lib acessllib_static_rtlStatic : : <name>ACE_SSLs <toolset>msvc
   <variant>release <search>$(ACE_ROOT)/lib ;
lib acessllib_static_rtlStatic : : <name>ACE_SSLs <toolset>msvc
   <variant>releaseWithAssert <search>$(ACE_ROOT)/lib ;

   It'll most likely come out split into multiple lines, but you should
get the idea. This example specifies which exact library file to link to
in case you want to link to the ACE SSL networking library built for
static linking and with static runtime based on the current <toolset>
and <variant> feature values. You can easily modify (specialize) it to
work differently based on the <os> feature.

> If my app is just dependent on Boost stuff, would it make more sense
> to stop using the distribution-provided packages and instead just
> build Boost manually? Or even include it's source in my project?

   It is your choice but using Boost Build to automate your project's
build should have absolutely no impact on that decision. Whichever way
you decide to go, Boost Build can be configured to go with you. :-)

   My 'generic' suggestion would be not to include Boost sources in your
project and to use a pre-built boost distribution if possible. If you
need the Boost library's build system customized you can easily build
Boost from its sources yourself and that should make no difference to
your project's build system other than possibly causing you to redirect
it to a different place to take Boost libraries/sources from.

> Am I correct that I can simply reference boost as a dependent project
> and that bjam will build the parts that I need as part of building my
> app?
> I guess that is more elegant. Is it good practice to go that route?

   If you build the Boost library from its sources you can also make
your project's build use the Boost library's Boost Build targets but I
would not recommend this as your first choice. This becomes useful when
you want to tweak the Boost library code but it also couples you to the
Boost library's build system and gets you more opportunity for things
breaking with the next Boost library release.

   On a related note, Boost libraries provide auto-linking features
which work great on platforms on which they are available, e.g. msvc
(unfortunately, gcc is not one of them :-(). When you use them you do
not have to specify explicitly which Boost library (based for example on
whether you are building a debug or release variant of your project or
whether you are using statically or dynamically linked run-time library)
to link to as it already knows which one it needs and all you need to do
is provide it with the folder in which to search for the libraries it needs.

   Hope this helps.

   Best regards,
     Jurko Gospodnetić

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at