Table of Contents
This section will guide you though the most basic features of Boost.Build V2. We will start with the “Hello, world” example, learn how to use libraries, and finish with testing and installing features.
The simplest project that Boost.Build can construct is stored in
example/hello/ directory. The project is described by
a file called Jamroot that contains:
exe hello : hello.cpp ;
Even with this simple setup, you can do some interesting things. First of
all, just invoking bjam will build the hello
executable by compiling and linking hello.cpp
. By default, debug variant is built. Now, to build the release
variant of hello, invoke
bjam release
Note that debug and release variants are created in different directories,
so you can switch between variants or even build multiple variants at
once, without any unnecessary recompilation. Let us extend the example by
adding another line to our project's Jamroot:
exe hello2 : hello.cpp ;
Now let us build both the debug and release variants of our project again:
bjam debug release
Note that two variants of hello2 are linked. Since we
have already built both variants of hello, hello.cpp
will not be recompiled; instead the existing object files will just be
linked into the corresponding variants of hello2. Now
let us remove all the built products:
bjam --clean debug release
It is also possible to build or clean specific targets. The following two
commands, respectively, build or clean only the debug version of
hello2.
bjam hello2 bjam --clean hello2