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).
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.
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/amd64 folders) and run
bootstrap.bat, which will generate
bjam right in the root.
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
bjam --helpsays!) 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.
prefixis the folder where the libraries and include files will be copied to eventually.
linkspecifies 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,
address-model=64tells 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
threading=multitells 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-namedisables building some libraries.
installtells 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
Reformatted the command lines, and updated my build command line to use the
--with-library commands instead of the