From the Boost mailing list I understand that VS2017 has the following version numbers that we would probably be most interested in:
Visual Studio 15.0
cl; C/C++ Compiler 19.10
Platform Toolset: v141
The following macros are defined in the Visual Studio 2017 IDE:
CrtSDKReferenceVersion 14.0
MSBuildToolsVersion 15.0
PlatformToolsetVersion 141
VCToolsVersion 14.10.25017
VisualStudioVersion 15.0
During compilation the following variables are #define
'd:
_MSC_VER 1910
_MSC_FULL_VER 191025017
cl.exe
is contained within an MSVC folder with the VC tools version. The complete x64
folder path is
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64
cl /Bv
from the command line lists:
Compiler Passes:
cl.exe: Version 19.10.25017.0
c1.dll: Version 19.10.25017.0
c1xx.dll: Version 19.10.25017.0
c2.dll: Version 19.10.25017.0
link.exe: Version 14.10.25017.0
mspdb140.dll: Version 14.10.25017.0
1033\clui.dll: Version 19.10.25017.0
Notice mspdb140.dll
and link.exe
are listed with version 14.10.25017.0.
And here it seems that msvc : 14.1
should be used as the toolset for boost. And here is another answer where some comments talk about boost's compiler naming.
When I compile I get the libraries names with v141 e.g.: boost_atomic-vc141-mt-1_64.lib
But in CMake the _Boost_GUESS_COMPILER_PREFIX
function has the following:
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
set(_boost_COMPILER "-vc150")
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
set(_boost_COMPILER "-vc140")
So which version should be used? vc141
or vc150
? Does
v141
implyvc141
, or doesv141
implyvc150
?
In order to answer this it would be best to start with
So, on my system:
It seems clear that the toolset version should be the main reference. Especially if one considers that VS 2017 can build both with
v140
andv141
. The toolset neatly defines both the compiler and linker.So then, what does it mean to compile Boost with
b2 toolset=msvc-14.0
for example? My contention is that it means toolsetv140
, not Microsoft Visual C++14.0
.How would one compile with toolset
v141
? Informally msvc is usually the VS number (e.g.15.0
for VS2017 on my system), but that would be inaccurate when specifying a toolset. Next, we note that Boost will create a file with a name containingvcXXX
wherevc
would again seem to imply the informal notion of a Visual C++ version number such as15.0
but certainly cannot refer to that as it is the toolset that is being specified.So, compiling for the latest toolset on VS2017 the command would be
b2 toolset=msvc-14.1
which will generate libraries with filenames containingvc141
. It would have been less confusing had it beenv141
, but then there would have been no reminder that we're dealing with the Microsoft toolset.I now think of the command as follows:
Finally we can consider the CMake function in
FindBoost.cmake
. The_boost_COMPILER
should default to-vc141
if the compiler version is19.10
.CMake versions which are less than the official release v3.8.0, which includes the rc numbers have the following in their FindBoost.cmake.
which means that, if your Boost dlls are not named like e.g. boost_date_time-vc150-mt-1_55.dll they won't be found. Version v3.8.0 started matching the approach Boost was taking with regard to version numbers, though I don't recall the in depth discussion of the matter. The short answer is though, if you are using a cmake version v3.8.0 or greater, you need the following instead.
For simplicity, in my Boost builds for Windows, I always add the following CMake code..
That lets me forget about the whole issue of what the libraries should be named.