Building Boost on Windows

Boost Logo

From time to time I find myself building Boost on Windows. There's a number of small things that need to be done to make that happen. Having had to "rediscover" the build process each time, I recently decided to create a small Windows command script to automate most of the process.

As I find the build script extremely useful, I figured it would be worth posting it here to inspire others in similar circumstances.

Process Overview

The overall build process is simple:

  1. Download and install the necessary tools.
  2. Download the sources.
  3. Download the build script.
  4. Update paths and version numbers in the build script, as necessary.
  5. Run the build script.
The build script itself will, for each build type (release / debug, 32-bit / 64-bit):
  1. Extract the Boost source to a build sub-directory.
  2. Configure the Windows SDK for the appropriate build type, if necessary.
  3. Configure and build Boost.

External Tools

Tip: you can find direct links to most of the software listed below on the Boost Links page.

The build script requires a valid Visual C++ installation - Express editions are fine. If using an Express edition prior to 2012, then you should also install a recent (eg 7.1) Windows SDK for 64-bit support.

For Boost's MPI support, install a Microsoft HPC Pack - not 2012 though, that version does not include the required headers / libraries.

For Python support, install the official Python Windows binaries - install both 32-bit and 64-bit versions.

Oh, and the build script uses 7zip to extract the various sources, so install that too.

Sources

At the very least you need the relevant Boost source... naturally.

Additionally, you can (recommended) include bzip2 and zlib sources to enable Boost's support for those. Note, if downloading zlib, be sure to downoad the source, not the compiled DLL release for Windows - the latter is 32-bit only.

My Boost build script expects to find the above sources within a source directory in its current location. The directory layout should look like:

Note, the following script has been moved to github: https://github.com/pcolby/boost-win

So check there for the latest version.

The build script will create a build directory (if not already present) for the generated build files.

build.cmd

So, here's the build script:

I've tested this script with:

These all build cleanly (actually some libs are skipped by Boost when using Python 3+), but I certainly haven't tested all of Boost's features, so there probably will be a few issues yet to be sorted out. And no doubt other versions of the tools / sources will bring their own issues too.

What's Next

The next step is packaging... I've already created a basic set of NSIS install scripts for generating installers for the generated Boost files. I'll finalise, and post those scripts in another blog post soon.

After that, I plan on putting together a short screencast to show the entire process, from a clean Windows install to a Boost Windows installer.

I might also look for somewhere to host the generated installers publically... if there's enough interest for that.

Attachments

comments powered by Disqus