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

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 http://svn.boost.org/svn/boost/trunk. 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!).

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-trunklink=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 x64Copyright (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 used to build Boost today:

bjam –build-dir=..\tmp\build –prefix=..\install-trunk link=static debug releaseaddress-model=64 threading=multi –toolset=msvc-9.0 –without-python –without-mpi–without-wave –without-thread install

This entry was posted on Saturday, December 29th, 2007 at 16:14 and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

By Lu Jun

80后男,就职于软件行业。习于F*** GFW。人生48%时间陪同电子设备和互联网,美剧迷,高清视频狂热者,游戏菜鸟,长期谷粉,临时果粉,略知摄影。

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.