使用Visual Studio 2017项目构建,但_MSC_VER显示1900

时间:2018-05-13 21:38:33

标签: visual-studio-2017 static-libraries solution vcxproj

我有一个项目的问题,也许有人可以给我一些提示。我在解决方案中有一个项目,最后一次使用Visual Studio 2015创建或更新。现在,我想用Visual Studio 2017构建这个项目。

因此,我使用参数启动批处理文件%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat amd64。然后,我使用命令devenv solution.sln /Upgrade升级项目。我看到以下输出:

Microsoft Visual Studio 2017 Version 15.0.27703.1.
Copyright (C) Microsoft Corp. All rights reserved.
Upgrading project 'project1'...
    Configuration 'Debug|Win32': changing Platform Toolset to 'v141' (was 'v140').
    Configuration 'Debug|x64': changing Platform Toolset to 'v141' (was 'v140').
    Configuration 'Release|Win32': changing Platform Toolset to 'v141' (was 'v140').
    Configuration 'Release|x64': changing Platform Toolset to 'v141' (was 'v140').

Migration completed successfully, but some warnings were detected during migration.
For more information, see the migration report:
C:\path\to\project\UpgradeLog.htm

在此UpgradeLog.htm中,我只看到此警告:

solution.sln: Visual Studio needs to make non-functional changes to this project in order to enable the project to open in released versions of Visual Studio newer than Visual Studio 2010 SP1 without impacting project behavior.

然后,当项目构建时,我在构建项目时看到此消息(我删除了真实的项目名称,源文件的名称和实际路径。这不应该是一个问题) :

ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\CL.exe /c /Iinclude /IC:\path\to\other\include /Zi /nologo /W3 /WX- /diagnostics:classic /MP /O2 /Ob2 /Ot /Oy- /GL /D WIN64 /D NDEBUG /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Release\x64\\" /Fd"C:\path\to\debug\symbols\debug.pdb" /Gd /TP /FC /errorReport:queue c1.cpp c2.cpp c3.cpp
  c1.cpp
  c2.cpp
  c3.cpp
  Unknown compiler version - please run the configure tests and report the results
  Unknown compiler version - please run the configure tests and report the results
  Unknown compiler version - please run the configure tests and report the results
Lib:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\Lib.exe /OUT:"C:\path\to\lib\project.lib" some_other.lib /LIBPATH:C:\path\to\other\lib64 /NOLOGO /MACHINE:X64 /LTCG Release\x64\c1.obj
  Release\x64\c2.obj
  Release\x64\c3.obj

但是后来,当我使用命令project.lib_MSC_VER文件中搜索find "_MSC_VER" project.lib时,我得到了这个输出(多次):

/FAILIFMISMATCH:"_MSC_VER=1900"

但我希望获得此输出(因为使用Visual Studio 2017构建):

/FAILIFMISMATCH:"_MSC_VER=1910"

这是怎么回事?

1 个答案:

答案 0 :(得分:1)

/FAILIFMISMATCH:"_MSC_VER=1900"表示该文件是使用MSVC++ 14.0 (Platform Toolset v140)构建的。因为根据升级日志,project1已迁移到v141,我认为:

  • 它尚未重建,您正在链接旧的.obj文件;或
  • 您看到的消息来自其他人构建的对象文件 针对v140的项目。

关于编译时消息,我怀疑您不迟于1.62使用Boost库 - 您可以在visualc.hpp header底部看到版本检查和消息。如果是这种情况,您需要更新Boost库或将Platform Toolset更改回v140。