Skip to content

Building Boost C++ libraries with Microsoft Visual C++ 14.0 (Visual Studio Community 2015)

Today we will build Boost C++ libraries (http://www.boost.org/) using Microsoft Visual C++ 14.0 compiler (Visual Studio Community 2015).

We will build both 32 bit and 64 bit binaries.

Download and extract files

Download the latest release (at this time Boost 1.59.0 hosted on SourceForge) http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.zip/download

Extract the files to a directory of your choice; I use /lib_source/

I like to keep my third party libraries separate from my own projects. I copy the final compiled binary files to a separate location, depending on the compiler used. For MSVC 2015 the folder is /lib_msvc14 (for MinGW it might be /lib_mingw47). You get the idea.

Read the documentation

In the extracted folder /lib_source/boost_1_59_0/ there will be an index.htm and an index.html (they seem to be identical), go and read the section on Getting Started now.

Install Boost.Build

Boost.Build is an automated build system, designed to support many different compilers. It allows the entire Boost library to be easily built in one step from the command line.

  • Open a command prompt and go to /lib_source/boost_1_59_0/tools/build/
  • Run bootstrap.bat
  • Run the following command which installs Boost.Build to /lib_source/boost_1_59_0/boost.build/
  • b2 --prefix=/lib_source/boost_1_59_0/boost.build install
  • Add C:\lib_source\boost_1_59_0\boost.build\bin to your PATH environment variable (restart your command prompt for this to take effect). Note the path ends in "\bin".

Build Boost

  • Open a command prompt and go to /lib_source/boost_1_59_0/
  • Run the following to build 32 bit binaries. The intermediate files will be placed in the build-dir directory; the final output will be copied to the stagedir directory. Note the output has been piped to a log file using "> build.log 2>&1", so no output will be shown on the console. Be patient, the build will take some time!
  • b2 --build-dir=build_msvc14 toolset=msvc --build-type=complete --stagedir=stage_32 > build32.log 2>&1
    
  • Examine the logs for any errors before building the 64 bit binaries:
  • b2 --build-dir=build_msvc14_64 toolset=msvc address-model=64 --build-type=complete --stagedir=stage_64 > build64.log 2>&1

Copy over output to final destination

I like to copy things over manually so that I can make sure nothing gets missed:

  • copy folder /lib_source/boost_1_59_0/boost to /lib_msvc14/boost_1_59_0/boost
  • copy folder /lib_source/boost_1_59_0/stage_32/lib to /lib_msvc14/boost_1_59_0/libx86
  • copy folder /lib_source/boost_1_59_0/stage_64/lib to /lib_msvc14/boost_1_59_0/libx64

Final notes

In case more than one version of msvc is installed, specify the compiler version to use with:

toolset=msvc-14.0

Once everything has been copied across and confirmed working, delete the intermediate folders build_msvc14build_msvc14_64stage_32 and stage_64 to save some disk space.

Create the following environment variables, to help with setting up projects:

Boost_DIR = C:\lib_msvc14\boost_1_59_0
BOOST_ROOT = C:\lib_msvc14\boost_1_59_0

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options