Visual Studio 2017 has been released, and it wasn’t exactly trivial to get previous versions of boost (1.63 and down) or next versions 1.67 and 1.68 to build with it.
There were a multitude of difficulties, but the two main problems are:
Unless a boost release doesn’t support a particular version of Visual Studio, it isn’t very easy to build boost with it.
Boost 1.64 was released 20th of April 2017 and can be downloaded from http://www.boost.org/users/history/version_1_64_0.html.
New in Boost 1.64 is a library called Boost.Process. It has been in development since 2006 and provides a cross platform way of spawning child processes and communication through synchronous or asynchronous streams.
For the impatient, scripts are available at Github: https://github.com/Studiofreya/boost-build-scripts.
Boost 1.64 is the first Boost release after Visual Studio 2017 was released 7th of March 2017. This time they haven’t slapped 2017 over 2015. Microsoft have redone the installer, the (internal) location of the tools and it is possible to have multiple versions of Visual Studio 2017 installed, each with their own set of available tools.
build_boost_1_64_vs2017.bat
in the same folder as boost_1_64_0
with the following contents:@echo off rem Directory to boost root set boost_dir=boost_1_64_0 rem Number of cores to use when building boost set cores=%NUMBER_OF_PROCESSORS% rem What toolset to use when building boost. rem Visual Studio 2012 -> set msvcver=msvc-11.0 rem Visual Studio 2013 -> set msvcver=msvc-12.0 rem Visual Studio 2015 -> set msvcver=msvc-14.0 rem Visual Studio 2017 -> set msvcver=msvc-14.1 set msvcver=msvc-14.1 rem Start building boost echo Building %boost_dir% with %cores% cores using toolset %msvcver%. cd %boost_dir% call bootstrap.bat rem Most libraries can be static libs b2 -j%cores% toolset=%msvcver% address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64 b2 -j%cores% toolset=%msvcver% address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32 b2 -j%cores% toolset=%msvcver% address-model=64 architecture=x86 link=shared threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64 b2 -j%cores% toolset=%msvcver% address-model=32 architecture=x86 link=shared threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32 pause
This script has been tested with a clean install of Windows 10 and a minimal install of Visual Studio 2017 with C++.
The process is mostly the same as with 1.64. If you are having problems and getting errors like “Unknown compiler version…” or “Failed to build Boost.Build engine…”, please, see our comment section.
The latest update to Visual Studio 2017 (15.5) may create some issues with existing code. See Visual Studio 2017 with C++17 and Boost for more details.
This bat file can be adjusted to build Boost 1.64 with Visual Studio 2012, 2013, 2015 and 2017 by adjusting the msvcver
variable.
set msvcver=msvc-11.0
set msvcver=msvc-12.0
set msvcver=msvc-14.0
set msvcver=msvc-14.1
Guide on how to use Boost 1.64 in VS2017 or any of the previous versions of Visual Studio.
Use the comment section if there are any questions.