1.10. Building a Complex application Using Boost.Build
Problem
You wish to use Boost.Build to build an executable that depends on several static and dynamic libraries.
Solution
Follow these steps:
For each library on which the executable depends—unless it is distributed as a prebuilt binary—create a Jamfile as described in Recipe 1.8 and Recipe 1.9.
Create a Jamroot file in the directory where you want the executable to be created.
In the file Jamroot, invoke the
exerule to declare an executable target. Specify your .cpp files and the library targets on which the executable depends as sources. Also, add properties of the form<include>pathas sources, if necessary, to tell the compiler where to search for library headers.In the file Jamroot, invoke the
installrule, specifying the properties<install-dependencies>on,<install-type>EXE, and<install-type>SHARED_LIBas requirements.Run bjam from the directory containing Jamroot as described in Recipe 1.7.
For example, to build an executable from the source files listed in Example 1-3, create a file named Jamroot in the directory hellobeatles as shown in Example 1-13.
Example 1-13. A Jamfile to build the executable hellobeatles.exe or hellobeatles
# Jamfile for project hellobeatles
exe hellobeatles
: # sources
../johnpaul//libjohnpaul
../georgeringo//libgeorgeringo
hellobeatles.cpp
;
install dist
: # sources
hellobeatles
: # requirements
<install-dependencies>on
<install-type>EXE
<install-type>SHARED_LIB
<location>.
;Now enter:
> bjam hellobeatles ...