3

CMake 2.8.10.2 for Windows 只是拒绝使用 Visual Studio 2012(在 Windows 7 下)为我配置项目

似乎 CMake 添加了一些 Microsoft 编译器不再支持的设置。 链接:致命错误 LNK1117:选项“清单:嵌入”中的语法错误

我尝试使用非常基本的 cmake 文件得到了相同的结果

cmake_minimum_required (VERSION 2.6)
add_executable(test test.cpp)

有解决办法吗?

输出窗口显示:

The C compiler identification is MSVC 17.0.51106.1
The CXX compiler identification is MSVC 17.0.51106.1
Check for working C compiler using: Visual Studio 11
Check for working C compiler using: Visual Studio 11 -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/Program Files (x86)/Microsoft Visual Studio
  11.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/tmp/testCmake/build/CMakeFiles/CMakeTmp



  Run Build Command:C:\PROGRA~2\MICROS~2.0\Common7\IDE\devenv.com
  CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec3122367237



  Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.51106.1.

  Copyright (C) Microsoft Corp.  All rights reserved.

  1>------ Build started: Project: cmTryCompileExec3122367237, Configuration:
  Debug Win32 ------

  1> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01
  for 80x86

  1> Copyright (C) Microsoft Corporation.  All rights reserved.

  1> 

  1> cl /c /Zi /W3 /WX- /Od /Ob0 /Oy- /D WIN32 /D _WINDOWS /D _DEBUG /D
  "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise
  /Zc:wchar_t /Zc:forScope /Fo"cmTryCompileExec3122367237.dir\Debug\\"
  /Fd"C:/tmp/testCmake/build/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec3122367237.pdb"
  /Gd /TC /analyze- /errorReport:prompt /Zm1000 testCCompiler.c

  1> 

  1> testCCompiler.c

  1>LINK : fatal error LNK1117: syntax error in option 'manifest:embed'

  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
  ==========





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):



Configuring incomplete, errors occurred!
4

3 回答 3

3

CMake 2.8 works well with Visual Studio 2012.

In the log you provided, note that CMake invokes Visual Studio 2012, which in turn invokes the compiler of Visual Studio 2008 (15.x; the compiler of VS2012 should be 17.x):

Microsoft (R) Microsoft Visual Studio 2012 Version 11.0.51106.1.

[...]

1> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86

This probably means your installation of VS2012 is configured to use the toolset of VS2008. It probably means the same thing is happening when you build directly in Visual Studio and not only via CMake.

This may be caused by unintended changes to the property sheet Microsoft.Cpp.Win32.user.props (or Microsoft.Cpp.x64.user.props, if you are building for x64). These files reside in %LOCALAPPDATA%\Microsoft\MSBuild\v4.0. If you see the directories of VS2008 referenced in any of these property sheets, this is likely the source of your problems.

To fix this, you can either manually edit the said file (completely removing the XML elements that refer to VS2008 folders), or just follow the steps given in this answer:

  1. Open any C++ project in Visual Studio 2012.
  2. Open View -> Other Windows -> Property Manager
  3. Double click on Microsoft.Cpp.Win32.user
  4. Go to VC++ Directories
  5. Rows which have been changed are bold. on all bold rows, click inside the text field, then on the Dropdown menu select inherit from parent or Project Defaults
  6. Click Apply, save and then close the dialog.
于 2014-05-13T08:48:05.903 回答
0

这对我不起作用。但是我能够删除有问题的文件(C:\Users\\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props)并且 Visual Studio 刚刚重新创建了该文件。VS2012 和 2013 都解决了问题。

于 2016-02-12T23:57:07.910 回答
0

我也收到错误:

链接:致命错误 LNK1117:选项“清单:嵌入”中的语法错误

它发生在 Windows 7、Visual Studio 2013 社区下。

我尝试了许多解决方案,唯一有效的方法是从我的计算机中完全删除 Visial Studio 2010。没有其他工作。我找到了一个问题,在 VS2013 中,变量 $VCInstallDir 仍然指向 2010 安装。因此,这导致了错误的 LibarayPath 设置和使用了错误的工具链执行程序(即使我有正确的“PlatformToolset”设置)。

总结一下:

  1. 您需要在您的项目中具有正确的“PlatformToolset”设置,并且在您依赖的所有库项目中具有相同的设置
  2. 您需要通过检查 $LibraryPath 是否正确来确保使用了正确的库目录,除非您直接在项目设置中覆盖它,否则它将通过 Visual Studio 内部自动化依赖于 $VCInstallDir,因此还要检查该变量
  3. 要解决问题 2,您可能必须删除 Visual Studio 2010,因为它会造成混乱,并且可能没有其他解决方案。
于 2016-04-21T11:26:26.653 回答