C++ 使用 MSVC 14.0 (VS 2015) 编译 Boost 时出现未知的编译器版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30760889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 13:48:33  来源:igfitidea点击:

Unknown compiler version while compiling Boost with MSVC 14.0 (VS 2015)

c++boostvisual-studio-2015

提问by OmegaExtern

I get "Unknown compiler version - please run configure tests and report the results" while attempting to compile Boost library on my computer.
I have most recent Boost (as of date of the post) - 1.58.0.
Doesn't Boost support MSVC 14.0, yet? How do I "run the configure tests"?

尝试在我的计算机上编译 Boost 库时,我收到“未知的编译器版本 - 请运行配置测试并报告结果”。
我有最新的 Boost(截至发帖日期)- 1.58.0。
Boost 不支持 MSVC 14.0 吗?我如何“运行配置测试”?

Screenshots.

截图.

回答by doqtor

Latest (at the time of posting this answer) Boost 1.58does support MSVC 14.0 Previewwhich was the latest MS compiler at the time of Boost 1.58 release. Now, the latest version of Visual Studiois 2015 RCwhich isn't covered in the boost 1.58 config file.

最新的(在发布此答案时) Boost 1.58确实支持MSVC 14.0 Preview,它是 Boost 1.58 发布时最新的 MS 编译器。现在,最新版本的Visual Studio2015 RC,它没有包含在 boost 1.58 配置文件中。

To stop Boost 1.58 complaining about unknown compiler version edit boost/config/compiler/visualc.hppand replace:

要停止 Boost 1.58 抱怨未知的编译器版本,请编辑boost/config/compiler/visualc.hpp和替换:

// last known and checked version is 19.00.22129 (VC14 Preview):
#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190022310)

with:

和:

// last known and checked version is 19.00.22816 (VC++ 2015 RC):
#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190022816)

which you can find is already done in boost repo herefor upcoming Boost 1.59 release.

您可以在此处为即将发布的 Boost 1.59 版本找到 boost repo 。

Update: For Visual Studio 2015 RTMset it to:

更新:对于Visual Studio 2015 RTM将其设置为:

// last known and checked version is 19.00.23026 (VC++ 2015):
#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023026)

Update2: For Visual Studio 2015 Update 1set it to:

UPDATE2:对于的Visual Studio 2015年更新1将其设置为:

// last known and checked version is 19.00.23506 (VC++ 2015 Update 1):
#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023506)


Also if you have previously been running Boost.Build on toolset=msvc-14.0then delete from C:\Users\<name>\AppData\Local\Tempthe following cached files:

此外,如果您之前一直在运行 Boost.Build,toolset=msvc-14.0则从C:\Users\<name>\AppData\Local\Temp以下缓存文件中删除:

b2_msvc_14.0_vcvarsall_x86.cmd 
b2_msvc_14.0_vcvarsall_x86_amd64.cmd 
b2_msvc_14.0_vcvarsall_x86_arm.cmd

More about that here.

更多关于这里

Update3For future reference, in your Visual Studio Tools Command Prompt run the command cl /Bvto see your version numbers (the parameters are case sensitive).

Update3为了将来参考,在您的 Visual Studio 工具命令提示符中运行该命令cl /Bv以查看您的版本号(参数区分大小写)。

Mine outputs the following:

我的输出如下:

C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x64\cl.exe:        Version 19.11.25506.0
 C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x64\c1.dll:        Version 19.11.25506.0
 C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x64\c1xx.dll:      Version 19.11.25506.0
 C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x64\c2.dll:        Version 19.11.25506.0
 C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x64\link.exe:      Version 14.11.25506.0
 C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x64\mspdb140.dll:  Version 14.11.25506.0
 C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC.11.25503\bin\HostX64\x6433\clui.dll: Version 19.11.25506.0

From this you can deduce the _MSC_VERis 1911 (from the text "Version 19.11") and the _MSC_FULL_VERis 191125506.

由此您可以推断出_MSC_VER是 1911(来自文本“版本 19.11”)和_MSC_FULL_VER是 191125506。

回答by Arnaud

Edit boost/config/compiler/visualc.hppand replace the test about the last known and checked version with one of the following line:

boost/config/compiler/visualc.hpp使用以下行之一编辑并替换有关最后一个已知和检查版本的测试:

1) If you want to deactivate completely the version check:

1) 如果要完全停用版本检查:

#if 0

2) If you want to check the major version only (select a single line):

2)如果您只想检查主要版本(选择一行):

#if (_MSC_VER > 1900) // Visual Studio 2015
#if (_MSC_VER > 1911) // Visual Studio 2017 15.0, 15.1 and 15.2
#if (_MSC_VER > 1911) // Visual Studio 2017 15.3 and 15.4
#if (_MSC_VER > 1912) // Visual Studio 2017 15.5
#if (_MSC_VER > 1913) // Visual Studio 2017 15.6
#if (_MSC_VER > 1914) // Visual Studio 2017 15.7
#if (_MSC_VER > 1915) // Visual Studio 2017 15.8
#if (_MSC_VER > 1916) // Visual Studio 2017 15.9
#if (_MSC_VER > 1920) // Visual Studio 2019 16.0

3) If you want to check both the major and minor version (select a single line):

3) 如果要同时检查主要和次要版本(选择一行):

#if (_MSC_VER > 1900 && _MSC_FULL_VER > 190023506) // Visual Studio 2015 Update 1
#if (_MSC_VER > 1900 && _MSC_FULL_VER > 190023918) // Visual Studio 2015 Update 2
#if (_MSC_VER > 1900 && _MSC_FULL_VER > 190023918) // Visual Studio 2015 Update 3
#if (_MSC_VER > 1910 && _MSC_FULL_VER > 191025017) // Visual Studio 2017 15.0, 15.1 and 15.2
#if (_MSC_VER > 1911 && _MSC_FULL_VER > 191125542) // Visual Studio 2017 15.3 and 15.4
#if (_MSC_VER > 1912 && _MSC_FULL_VER > 191225835) // Visual Studio 2017 15.5
#if (_MSC_VER > 1913 && _MSC_FULL_VER > 191326132) // Visual Studio 2017 15.6
#if (_MSC_VER > 1914 && _MSC_FULL_VER > 191426433) // Visual Studio 2017 15.7
#if (_MSC_VER > 1915 && _MSC_FULL_VER > 191526726) // Visual Studio 2017 15.8
#if (_MSC_VER > 1916 && _MSC_FULL_VER > 191627030) // Visual Studio 2017 15.9
#if (_MSC_VER > 1920 && _MSC_FULL_VER > 192027508) // Visual Studio 2019 16.0

回答by rkellerm

In general, open boost/config/compiler/visualc.hppand hover the mouse over _MSC_FULL_VERto see the version installed on your environment.

通常,打开boost/config/compiler/visualc.hpp并将鼠标悬停在上面_MSC_FULL_VER以查看您的环境中安装的版本。

回答by Matt

Now using the fully released version of msvc-14.0 (Visual Studio 2015), you can use this:

现在使用完全发布的 msvc-14.0 (Visual Studio 2015) 版本,您可以使用它:

#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023026)

Is there any danger is this? Should we instead wait for the next release of Boost that has been officially edited to have this value?

这有什么危险吗?我们是否应该等待已正式编辑的下一个 Boost 版本具有此值?

回答by Atdhe Kurteshi

I have tried the following code in Ogre 1.9 - Visual Studio 2015.

我在 Ogre 1.9 - Visual Studio 2015 中尝试了以下代码。

Last known and checked version is 19.00.23506 (VC++ 2015 Update 1)

最后已知和检查的版本是 19.00.23506(VC++ 2015 更新 1)

if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023506)

if (_MSC_VER > 1800 && _MSC_FULL_VER > 190023506)