Boost logo

Boost-Build :

Subject: Re: [Boost-build] Linking with boost
From: J.L.Castillo (jlcastillolorenzo_at_[hidden])
Date: 2011-07-01 06:39:39


Hi,

I don't know how to do it with the approach you suggest. What I do is build
all Boost libraries and install them in a given path, that will be platform
dependent. Later I add the following to the Jamroot of my project:

path-constant TOP : . ;
use-project /lib : $(TOP) ;

constant PLATFORM : [ os.environ PLATFORM ] ;

if $(PLATFORM) = mingw
{
    constant boost_inc_path : "c:\\msys\\1.0\\local\\include\\boost-1.45" ;
    constant boost_debug_lib_path :
"c:\\msys\\1.0\\local\\lib\\boost-1.45d_gcc-4.5.0" ;
    constant boost_release_lib_path :
"c:\\msys\\1.0\\local\\lib\\boost-1.45r_gcc-4.5.0" ;
    constant boost_debug_suffix : "-mgw45-mt-d-1_45" ;
    constant boost_release_suffix : "-mgw45-mt-1_45" ;
    constant boost_needed_libs : z ole32 oleaut32 ws2_32 ;
}
else if $(PLATFORM) = linux
{
    constant boost_inc_path : "/usr/include/boost-1.45" ;
    constant boost_debug_lib_path : "/usr/lib/boost-1.45d_gcc-4.5.2" ;
    constant boost_release_lib_path : "/usr/lib/boost-1.45r_gcc-4.5.2" ;
    constant boost_debug_suffix : "" ;
    constant boost_release_suffix : "" ;
    constant boost_needed_libs : z ;
}
else if $(PLATFORM) = mac
{
    constant boost_inc_path : "/opt/local/include" ;
    constant boost_debug_lib_path : "/opt/local/lib" ;
    constant boost_release_lib_path : "/opt/local/lib" ;
    constant boost_debug_suffix : "-mt" ;
    constant boost_release_suffix : "-mt" ;
    constant boost_needed_libs : z ;
}

lib $(boost_needed_libs) : : <link>shared ;
alias boost_debug_common : $(boost_needed_libs) : <variant>debug : :
<linkflags>"-L\"$(boost_debug_lib_path)\"" <include>$(boost_inc_path) ;
alias boost_release_common : $(boost_needed_libs) : <variant>release : :
<linkflags>"-L\"$(boost_release_lib_path)\"" <include>$(boost_inc_path) ;

# define external library (how to find lib and where to look for include
files)
lib _boost_iostreams_debug : : <name>boost_iostreams$(boost_debug_suffix)
<search>$(boost_debug_lib_path) <variant>debug : ;
lib _boost_iostreams_release : :
<name>boost_iostreams$(boost_release_suffix)
<search>$(boost_release_lib_path) <variant>release : ;
alias boost_iostreams : _boost_iostreams_debug boost_debug_common :
<link>shared <variant>debug : : ;
alias boost_iostreams : _boost_iostreams_release boost_release_common :
<link>shared <variant>release : : ;
alias boost_iostreams : _boost_iostreams_debug boost_debug_common :
<link>static <variant>debug : : ;
alias boost_iostreams : _boost_iostreams_release boost_release_common :
<link>static <variant>release : : ;

The last part about IOSTREAMS should be repeated for every non-just-headers
Boost library you need to use. Later, in the Jamfile of the library or
executable, I would use it as follows:

exe myapp : somesource.cpp /lib//boost_iostreams ;

Regards.
Jose.

2011/6/30 Benjamin Lindley <benjameslindley_at_[hidden]>

> I just got started with Boost.Build. I've managed to get simple self
> contained projects with no outside dependencies working. Now I'm trying to
> figure out how to link with other libraries, starting with boost. This is
> what I have tried:
>
> Boost is installed in /Dev/C++/lib/boost_1_46_1
> My project directory is /Dev/C++/test/hello
>
> In my project directory is hello.cpp, and Jamroot.jam.
>
> Jamroot.jam:
>
> exe hello : hello.cpp ../../lib/boost_1_46_1 ;
>
> Then I try to build with this command:
>
> bjam toolset=gcc release
>
> Am I doing that right? I get the following output.
>
> configure.jam: No such file or directory
> ..\..\lib\boost_1_46_1\**Jamroot:219: in modules.load
> rule configure.register-components unknown in module
> Jamfile</C:/Users/Cold/Dev/C++**/lib/boost_1_46_1>.
> C:/Users/Cold/Dev/C++/boost-**build/build\project.jam:312: in load-jamfile
> C:/Users/Cold/Dev/C++/boost-**build/build\project.jam:68: in load
> C:/Users/Cold/Dev/C++/boost-**build/build\project.jam:170: in project.find
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:394: in find-really
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:410: in
> object(project-target)@33.find
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:861: in
> resolve-reference
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:880: in
> targets.generate-from-**reference
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:1170: in
> generate-dependencies
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:1224: in
> object(typed-target)@34.**generate
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:765: in
> generate-really
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:738: in
> object(main-target)@39.**generate
> C:/Users/Cold/Dev/C++/boost-**build/build\targets.jam:255: in
> object(project-target)@33.**generate
> C:/Users/Cold/Dev/C++/boost-**build\build-system.jam:414: in load
> C:\Users\Cold\Dev\C++\boost-**build/kernel\modules.jam:261: in import
> C:\Users\Cold\Dev\C++\boost-**build\kernel\bootstrap.jam:**132: in
> boost-build
> C:\Users\Cold\Dev\C++\boost-**build.jam:1: in module scope
> ______________________________**_________________
> Unsubscribe & other changes: http://lists.boost.org/**
> mailman/listinfo.cgi/boost-**build<http://lists.boost.org/mailman/listinfo.cgi/boost-build>
>



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