• Increase font size
  • Default font size
  • Decrease font size

Building projects depended from BOOST

Motto:    : Always code as if the person who will maintain your code is a maniac serial killer that knows where you live

(Note: if you want to build boost libraries try http://www.boostpro.com/download first - maybe you didn't need it)

(Note2: if you need specific library to solve problem and you are using windows try get compiled boost library)

I’ve sometimes get projects or files that depend on BOOST library. This task I repeat from one to another version of BOOST.  Du now I've used compiled for specific thread model version of this library - located in sources. But there is much more general method.

I’m using various compilers in various environments. In home I use express editions, in work of professional. Sometimes I meet problems with BOOST library and right environment to build sources without changing entire environment and rebuilding BOOST in specific mode.
Therefore I’ve prepared step-by-step guide that present how to prepare such environment for use under Windows. I assume that you have installed MSVC with required SDK.

First of all – you need to download boost library from www.boost.org and boost bjam building tool. There is no exception. Both tools are required. I’ve downloaded (14 june 2008) library 1.35 and bjam 3.1.16. Boost jam building tool (bjam.exe) is a tool that is required to build boost libraries – something like “make” tool.
When you download both files then you need unpack boost archive and bjam.exe file.

Where unpack?: In this scenario you can unpack this boost zip or 7z file in any directory – because we will build it directly in specified directory and the sources could be abandoned after build. But bjam.exe should appear in your path – I have c:\bin directory where I put such tools.

Then call cmd.exe and go to the boost unpacked directory …

cd C:\Documents and Settings\mwidera\Desktop\boost_1_35_0\boost_1_35_0

And call bjam

C:\Documents and Settings\mwidera\Desktop\boost_1_35_0\boost_1_35_0>bjam --build-type=complete --prefix="c:\boost"

Notice: This command will compile boost libraries in source directory

If you have various compilers and you want to let bjam deducing – use following instead

bjam --toolset=msvc --build-type=complete --prefix="c:\boost"

But in most cases if you have only MSCV installed this --toolset is deduced properly.

If you wish to build boost libraries under msvc (for instace from qtcreator) find "Qt command prompt" in windows menu then use following command:

bjam --toolset=gcc --build-type=complete --prefix="c:\boost"

Then you could go for large cup of tea (depending on machine speed) … It will take some time. This will build complete BOOST – and after that you shouldn’t meet any problems.

If you will interrupt this process (for instance by Ctrl+C) then use -a option to rebuild all ... so:

bjam --toolset=msvc --build-type=complete --prefix="c:\boost" -a

(In previous versions after building, I've issued then following command

bjam --build-type=complete --prefix="c:\boost" install )

If you wish to build addiotional python libraries - issue following command:

bjam --build-type=complete --prefix="c:\boost"  --with-python install

Following additional files will appear:


Time stats - please consider a few hours. (Depending on machine speed)

After installing you will see following directory structure:

C:\boost\include\boost-1_35\boost – and lots of hpp files
C:\boost\lib – and lots of lib files

You can also compile and use two differnet build enviroments (vs2005 and vs2008 if you wish )

This is the right boost installed system for MSCV.

As I notice on the beginning of the article – I use various compilers and MSCV’s
Therefore when I getting BOOST depended files I create separate project for given source files. (In fact .vcproj’s are incompatible each other)

So ... create, project - add required file and ...

Setting paths in visual studio environment for BOOST project.

Click right mouse button on given project – choose properties.

Window Compiler property pages, tree: Configuration Properties->linker->general->Additional Library Directories

Add following key



>digression: if you meet following error during linking:
>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-gd-1_36.lib'
>or LINK : fatal error .... cannot open file 'libboost_ something.lib
>then you probably forgot put this c:\boost\lib in general->additinal library directories key in properties window

and next …

Window Compiler property pages, tree: Configuration Properties->C/C++ -> Additional Include Directories

Add following key


Do not forget to set "All configurations"  - otherwise only debug or release will be configured properly.


(in mine projects I use environment variable as key %BOOST_DIR% instead)

And now - project that depends boost should compile ...

Next BOOST library - if they appear, will fit into this c:\boost directory seamless - new libs and dll's will just be appened. For such purpose you can use suggested %BOOST_DIR% enviroment variable or change Additional Include Directories key on demand.

Any other chagne in this project will not be required - (I hope).


What to do if there is no disk C: and you will try to build it ...  Then you problably will see following message:

failed common.mkdir C:\Boost...

Because you have not any disk C: ! - then you need to put additional option --build-dir="f:\boost\build_dir" - it should help

Similar links:

1. http://zenedith.wordpress.com/2008/06/23/bjam-boost/  (in Polish)
2. http://www.boost.org/doc/libs/1_38_0/more/getting_started/windows.html#prepare-to-use-a-boost-library-binary

Appendix 1:

What boost library name mean?

Library name follow following format:

+ "_"

These are defined as:

BOOST_LIB_PREFIX: "lib" for static libraries otherwise "".
BOOST_LIB_NAME: The base name of the lib ( for example boost_system ).
BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).
BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise "".
BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used, contains one or more of the following letters after a hiphen:

s static runtime (dynamic if not present).
d debug build (release if not present).
g debug/diagnostic runtime (release if not present).
p STLPort Build.

BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y.

Appendix 2:

Build boost 1.47 - 1.50 from source files via Qt Creator in Windows.

First get qt-creator from nokia site and install it in c:\qt directory.
Then boost_1_47_0.(whatever) from boost site and upack it. You need to build bjam and b2 tools first.
Go to boost_1_47_0\tools\build\v2 and find bootstrap.bat
Check in command line window gcc --version. If you cannot find gcc or version is other than 4.4.0 (that comes with Qt creator 2.3.0) then put

set path=C:\Qt\qtcreator-2.3.0\mingw\bin;%path% 

to your path in command line window.
now check again gcc --version
now type in command line window in directory boost_1_47_0\tools\build\v2 (in boost_1_47_0 it goes as well)

bootstrap.bat mingw 

If compilation will succed - you will see

Bootstrapping the build engine
Bootstrapping is done. To build, run:
    .\b2 --prefix=DIR install

Now type

 .\b2 --prefix="c:\boost" install

It will create c:\boost tree with bjam and b2 tools only. c:\boost\share and c:\boost\bin dirs will appear.
Then final step. Type in command line window in \boost_1_47_0 directory with boostcpp.jam file

c:\boost\bin\b2.exe --toolset=gcc --prefix=c:\boost install

This command should compile and create boost files.
I.e. C:\boost\include\boost-1_47\boost files and C:\boost\lib *.a files


Build boost 1.47 - 1.53 from source files in Linux (Ubuntu 12.04 LTS)

1. Download boost tar.gz package from Boost webpage
2. unpack tar xvf this package
3. cd unpacked directory

$ sudo ./b2 --prefix="/opt/boost" install
$ sudo vi /etc/profile.d/boost.sh

and add line

export BOOST_ROOT=/opt/boost


check in new terminal instance enviroment variable

. /etc/profile.d/boost.sh 

after enviroment restart boost_root will appear always

Build boost 1.47 - 1.53 from source files via MSVC 10  in Windows.

Build boost 1.47 - 1.50 from sources via Microsoft Visual Studio 2010 is trivial. Type


in \boost_1_47_0 directory in cmd.exe (shell) window. Then type

.\b2 --prefix="c:\boost" install

CMAKE 2.8 - How to add boost to project

I like to use Cmake with qt-creator as simple and portable solution for multiplatform development.
But I need to take some time configure CMakeList.txt file.
Here is a simple header for include some boost lib's that I use.

cmake_minimum_required(VERSION 2.8)

project( given_project_name )

FIND_PACKAGE( Boost COMPONENTS filesystem serialization regex program_options REQUIRED )

link_directories( ${Boost_LIBRARY_DIRS} )

Additionaly I declare following enviroment variable in Windows (If required):

BOOST_ROOT = c:\boost

To check additional options try:


cmake --help-module FindBoost


Additional sources:



Naszą witrynę przegląda teraz 2 gości