Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version numbers for Visual Studio 2017, Boost and CMake

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 imply vc141, or does
  • v141 imply vc150?
like image 583
wally Avatar asked Mar 11 '17 01:03

wally


People also ask

What version of .NET is Visual Studio 2017?

Visual Studio 2017 supports the following implementations: . NET Framework versions 4.7, 4.6.

What version of C++ is in Visual Studio 2017?

Visual Studio 2017 version 15.3/std:c++17 enables the set of C++17 features implemented by the compiler.

Is Visual Studio 2017 still supported?

Visual Studio 2017: mainstream support ends April 12, 2022, and the product will transition to extended support until April 2027. During extended support we'll provide fixes only for security issues. We recommend users move to the 15.9 supported baseline to remain under support.


2 Answers

In order to answer this it would be best to start with

  • how Microsoft structures its products
  • what Microsoft calls its products and
  • how Microsoft numbers them.

So, on my system:

Microsoft Visual Studio Community 2017 has version number 15.0.26228.4. It contains:
|
+--Visual C++, informally VS, informally MSVC 
   (no version number to be found, but it is reasonable to infer 15.0) 
   which uses tools, such as
   |
   +--Toolset v141, composed of
      |
      +--compiler cl.exe version 19.10.25017.0 and
      +--linker link.exe version 14.10.25017.0 which
         |
         +--refers to CrtSDK version 14.0, and
         +--uses mspdb140.dll version 14.10.25017.0

It seems clear that the toolset version should be the main reference. Especially if one considers that VS 2017 can build both with v140 and v141. 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 toolset v140, 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 containing vcXXX where vc would again seem to imply the informal notion of a Visual C++ version number such as 15.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 containing vc141. It would have been less confusing had it been v141, but then there would have been no reminder that we're dealing with the Microsoft toolset.

I now think of the command as follows:

b2 toolset=msvc-14.1
           ---- ----
             |    |
             |    +-- Toolset v141
             |
             +------- Microsoft Visual C++ (version 15.0)

Finally we can consider the CMake function in FindBoost.cmake. The _boost_COMPILER should default to -vc141 if the compiler version is 19.10.

like image 54
wally Avatar answered Oct 10 '22 09:10

wally


CMake versions which are less than the official release v3.8.0, which includes the rc numbers have the following in their FindBoost.cmake.

if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
  set(_boost_COMPILER "-vc150")

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.

  if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.10)
    set(BOOST_TOOLSET msvc-14.1)

For simplicity, in my Boost builds for Windows, I always add the following CMake code..

if(MSVC AND (NOT MSVC_VERSION LESS 1910))
  # Get the CMAKE version string and make sure it's not a release candidate and >= 3.8.0
  if( (CMAKE_VERSION MATCHES "^3\\.8\\.0-rc") OR (CMAKE_VERSION VERSION_LESS 3.8.0))
    message(FATAL_ERROR "CMake 3.8.0 is the minimum version required to use Boost with Visual Studio 2017 or greater")
  endif()
endif()

That lets me forget about the whole issue of what the libraries should be named.

like image 3
StAlphonzo Avatar answered Oct 10 '22 10:10

StAlphonzo