Using Boost Build

I use bjam and Boost.Build since a while and they are really great. You can easily use them to build multi-platform applications and they automatically resolve the C++ header dependencies, which is difficult to realize with make and makefiles. Writing Jamfiles is in principle easy, but in the beginning it is hard to figure out how it works, especially if you are following the official documentation. Today, I found an easy way to link the boost libraries and how easy the boost headers can be included: I always put boost in a local directory and set an environment variable BOOST_ROOT pointing to this folder. Then, I simply use Jamfiles like this

import boost ;
boost.use-project ; 

exe main : main.cpp : <library>/boost//filesystem ;

The first two lines include boost. Especially they will use now the boost include directory when the source code is compiled and they provide the aliases for the compiled boost-libraries. <library>/boost//filesystem simply links against the filesystem library. Of course, if you want to use other libraries you can simply add <library>/boost//iostreams, <library>/boost//date_time, <library>/boost//program_options, …

Edit: If you only need the header-only libraries of boost use <library>/boost/headers.

Leave a Reply

Your email address will not be published. Required fields are marked *