Building Boost from SVN trunk with Visual Studio 2008 (x86 & x64)

Welcome to the bleeding edge. Just switched to Visual Studio 2008, and you need Boost for your project? Then read on to see how you can build Boost from trunk with VC9 (actually, this also applies to VC8, and possibly even earlier versions, but I just tried with VC9).

Obtaining Boost

First of all, you need to get Boost. A detailed guide is available here, basically all you need to do is a SVN checkout of I got revision 42333, which I'll use for the rest of this article.

Building Boost

Boost uses a custom build system, Boost.Build v2. Just take a look at the detailed manual to see how big the system is. Anyway, the first step is to build BJam, which is located in tools/build. Building is straightforward unless you have parentheses in your path - if so, read this earlier post describing the problem. Anyway, at the end, put the bjam.exe into the folder you just checked out from SVN (right to the index.html stuff!). [Update]: For recent Boost builds (I think 1.40 or later), you just have to open a Visual Studio command prompt (or call the vcvars*.bat file located in vc/bin / vc/bin/amd64 folders) and run bootstrap.bat, which will generate bjam right in the root.

Running Boost.Build

For this example, I'll assume you want to build the static-link libraries, x64, debug and release versions, and omit some libraries like Wave and Python to make things more interesting. Let's start like most programming examples, by looking right at the command line needed:

bjam --build-dir=..\\tmp\\build
--prefix=..\\install-trunk link=static,shared debug release
address-model=64 threading=multi --toolset=msvc-9.0 --without-python
--without-mpi install
  • build-dir (not builddir as bjam --help says!) sets the build directory where all the temporary files will end up. You do not want to have them in your source folder, so I simply moved them one folder up.
  • prefix is the folder where the libraries and include files will be copied to eventually.
  • link specifies the linkage of the files. I use static as it simplifies deployment and works nicely with the auto-link stuff and shared (which results in DLLs) just for this example ;)
  • Next the targets, debug and release.
  • address-model=64 tells BJam to use the x64 compiler. Otherwise, even if you run the x64 command prompt, it will generate x86 binaries. If you want x86 binaries, specify address-model=32.
  • threading=multi tells the compiler to link against the multi threaded-CRT -- this is actually no issue for VC9 as there is no single-threaded CRT but I added it here just to be sure.
  • The toolset, to avoid guesswork, I specified the full compiler version.
  • --without-name disables building some libraries.
  • install tells BJam to copy the files to the prefix folder. This generates a folder called libs where the libraries end up and a folder include with the include files.

Those options are also explained in the builtin features section of the manual. You need to start this from the Visual C++ Command prompt -- verify that you are running it by typing cl, it should give you something like:

Microsoft (R) C/C++ Optimizing Compiler
Version 15.00.21022.08 for x64 Copyright (C) Microsoft Corporation. All

rights reserved.

Well, that's it basically, now you need some patience, and you should get a perfect working version of Boost tailored at your needs with just the libraries you want. For the sake of completeness, here the command line I use to build Boost:

bjam --build-dir=..\\tmp\\build
--prefix=..\\install-trunk-x64 link=static debug release
address-model=64 threading=multi --toolset=msvc-9.0 --with-system
--with-filesystem --with-thread --with-date\_time
--with-program\_options --with-signals install

[Update] Reformatted the command lines, and updated my build command line to use the --with-library commands instead of the --without.


Comments powered by Disqus