Building the Boost libraries for VAOS

Note This page supersedes the old instructions which are still here for reference. If you need to rebuild a VAOS release earlier than 6.3.0.4 you will need to look at the old instructions.

The Boost library project provides a number of high-quality free sourcecode libraries for C++ development. Many of these are written in such a way that one need only include the appropriate Boost header file in the C++ source, but some are written to be compiled to object code libraries.

The VAOS codebase uses some of the Boost libraries, in particular for regular expression processing/ The Boost regex library is one of those that must be separately compiled so anyone wishing to build VAOS must first download Boost and build (at least) the regex library.

As Boost is continually being improved and refined we aim to use the most recent version of Boost for any VAOS release.

At the time of writing this the current VAOS release was 6.3.0.5 which was built with Boost version 1.46.1 using Visual Studio 2008. The readme file distributed with any VAOS version should note which Boost library version was used in the build.

The "Getting Started" instructions on the Boost website will be helpful. For Boost 1.46.1 these can be found here. Note that more recent versions of Boost are built slightly differently – always look at the current build instructions!

Get the Source

Download the Boost archive from here. You can download either the .zip or the .7z archive (the .7z archive is smaller, but requires the (free) 7zip tool to unpack it).

The archive contains a single directory named for the boost version (e.g. boost-1_46_1). Unpack this directory to a convenient location on your PC. Say: Q:\swdev\boost-1_46_1.

cd to that directory. This is where we shall build boost.

Preparation

Choose a directory for the output of the build process. This is typically just called "boost" (the build process allows multiple versions of Boost to be stored within this directory if needed). We shall use Q:\swdev\boost.

Run the Boost bootstrap process and pass it the path prefix of the output directory. This will, among other things, build a copy of the Boost version of the jam build tool.

.\boostrap --prefix=Q:\swdev\boost

Building Boost

There are a number of options that can be set when building Boost libraries. One can choose between static/dynamic linking, debug or release code, etc., and can opt to build only certain libraries of those available. The VAOS project files currently only require the regex library to be built, but I recommend building the default set of libraries as they may be useful for other projects. You may wish to suppress building of the Boost python libraries if you do not have python on your system – otherwise you will get a couple of harmless error messages.

For VAOS you will need static-linked libraries using a static-linked C++ runtime, in debug and release flavours.

In order to ensure that the Boost auto-linking feature works correctly when libraries are built with different options it is necessary to give the different libraries different names. This is done by telling the boost build system to build "versioned" libraries.

The commandline I use is:

.\bjam --prefix="Q:\SWDev\boost" toolset=msvc-9.0 --layout=versioned variant=debug,release link=static runtime-link=static threading=multi stage install

The build takes a long time ...

The "targets" here are "stage" and "install". the "stage" target cause the build to take place, and stores all the library files in the "stage" directory (Q:\swdev\boost-1_46_1\stage). The "install" target then copies all those libraries to the final output location. These operations are separate for security reasons: the final directory might be a system directory that could only be written with admin privileges, while the build might be performed by a non-admin user. Here I'm assuming that the user performing the build has rights to write to the final output directory and can run the stage and install tasks in a single command.

Note the explicit toolset=msvc-9.0 which ensures that the correct versioning information is included in the library names (and is necessary if you have more than one version of Visual Studio installed, to tell Boost which to use).

Note also that more recent versions of the Boost build documentation call the build tool "b2" rather than "bjam" (I have no idea why)!

Using Boost in Visual Studio

There are two ways that the Boost libraries can be accessed from within Visual Studio. One is by explicitly adding the libraries to the projects one is working with, the other is by adding them to the Visual Studio environment so that they will be available to all projects.

The project files in VAOS assume the second method.

  • In Visual Studio go to the "Tools" menu and select "Options".
  • In the options dialog select the "Projects and Solutions" entry in the tree on the left, then its "VC++ Directories" sub-entry.
  • At the top right of the dialog, under "Show directories for", select "Include files".
  • Add a new entry to the list of paths for Q:\swdev\boost\include\boost-1_46_1 (or whatever version you have built)
  • At the top right of the dialog, under "Show directories for", select "Library files".
  • Add a new entry to the list of paths for Q:\swdev\boost\lib

That's all!

Note that in earlier versions of VA the libraries were not built with the "versioned" option, and some extra code was needed in the VAOS source files to get the Boost auto-linking feature to work. This is no longer necessary and the code has been removed from VAOS since 6.3.0.4.

 
devinfo/boost_for_va.txt · Last modified: 01.02.2012 00:57 by daniel
 
Recent changes RSS feed Driven by DokuWiki