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.
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".
- 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
In case more than one version of msvc is installed, specify the compiler version to use with:
Once everything has been copied across and confirmed working, delete the intermediate folders build_msvc14, build_msvc14_64, stage_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