How to build Boost using Visual Studio

If your code compiled with Visual Studio needs Boost, you can get prebuilt Boost libraries. However, if your code needs to link with Boost library files, then the Visual Studio version used for your code and used to build Boost has to match. If you cannot find a prebuilt Boost library matching your Visual Studio then you might have to build Boost by yourself.

I had this problem since my code was using C++11 features that required Visual Studio 2015, but the prebuilt Boost libraries were only available for Visual Studio 2012.

To build Boost for Visual Studio, I followed these steps:

  • Download the source of Boost from here. Unzip it anywhere.

  • Open the Developer Command Prompt for Visual Studio. Change to the directory where Boost is unzipped.

  • Build the Boost.Build tool (b2.exe) using this command:

> bootstrap.bat
  • Build Boost using this compile invocation:
> b2 toolset=msvc-14.0 --build-type=complete --abbreviate-paths architecture=x86 address-model=64 install -j4

toolset: Use this to specify the Visual C++ compiler to use. For Visual Studio 2015, this is msvc-14.0. For other versions of Visual Studio see this post.

architecture: This is the processor architecture. Keep this x86 for both 32-bit and 64-bit builds!

address-model: Use this to specify whether you want 32 or 64 bit library to be built.

-j: Use this to specify how many cores to use for parallel compilation.

  • This compilation took about 30 minutes and after it is done, the Boost header files and built libraries are dumped in C:\Boost.

Note: Detailed steps to build Boost for Visual Studio can be found in this StackOverflow post.

Tried with: Boost 1.59, Visual Studio 2015 and Windows 7 x64

12 thoughts on “How to build Boost using Visual Studio”

  1. toolset is a feature, not an option, so it must not have the leading dashes. I.e. make that toolset=msvc-12.0 rather than --toolset=msvc-12.0. (It worked for you because the toolset was autodetected, the --toolset did nothing.)


  2. You might want to mention that the stack-exchange post tells user to compile via msvc-10.0 instead of msvc-12.0. I followed the stack exchange command and came out with the wrong files:/


  3. I tried this from the Developer Command Prompt for VS2013 for boost_1_58_0 and the bootstrap.bat still failed because it couldn’t find windows.h. Is there something wrong with boost_1_58_0 or could my Visual Studio VS13 not e configured correctly


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s