用Visual Studio 2012/2013打破CMake?

时间:2013-04-10 13:52:01

标签: visual-studio cmake

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

似乎CMake添加了一些Microsoft编译器不再支持的设置。    LINK:致命错误LNK1117:选项'manifest:embed'中的语法错误

我尝试使用非常基本的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!

3 个答案:

答案 0 :(得分:3)

CMake 2.8适用于Visual Studio 2012。

在您提供的日志中,请注意CMake调用Visual Studio 2012,后者又调用 Visual Studio 2008的编译器(15.x; VS2012的编译器应为17.x):

  

Microsoft(R)Microsoft Visual Studio 2012版本11.0.51106.1。

     

[...]

     

1> Microsoft(R)32位C / C ++优化编译器版本15.00.30729.01 for 80x86

这可能意味着您的VS2012安装配置为使用VS2008的工具集。这可能意味着直接在Visual Studio中构建时不会发生同样的事情,而不仅仅是通过CMake。

这可能是由于对属性表Microsoft.Cpp.Win32.user.props(或Microsoft.Cpp.x64.user.props)进行了意外更改(如果您正在为x64构建)。这些文件驻留在 %LOCALAPPDATA%\Microsoft\MSBuild\v4.0。如果你看到任何这些属性表中引用的VS2008的目录,这可能是你的问题的根源。

要解决此问题,您可以手动编辑所述文件(完全删除引用VS2008文件夹的XML元素),或者只需按照this answer中给出的步骤进行操作:

  
      
  1. 在Visual Studio 2012中打开任何C ++项目。
  2.   
  3. 打开查看 - >其他Windows - >物业经理
  4.   
  5. 双击 Microsoft.Cpp.Win32.user
  6.   
  7. 转到 VC ++目录
  8.   
  9. 已更改的行是粗体。在所有粗体行上,单击里面   在文本字段中,然后在下拉菜单中选择从父级继承   或项目默认值
  10.   
  11. 点击应用保存,然后关闭对话框。
  12.   

答案 1 :(得分:0)

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

答案 2 :(得分:0)

我也遇到了错误:

LINK:致命错误LNK1117:选项'manifest:embed'中的语法错误

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

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

总结一下:

  1. 您需要在项目中使用正确的“PlatformToolset”设置,并在所有依赖的库项目中使用相同的设置
  2. 你需要确保使用正确的库目录,通过检查$ LibraryPath是否正确,除非你直接在项目设置中覆盖它,它将依赖于$ VCInstallDir通过Visual Studio内部自动化,所以检查该变量< / LI>
  3. 要解决问题2,您可能不得不删除Visual Studio 2010,因为它会弄得一团糟,而且可能没有其他解决方案。