【问题标题】:CMake with Visual Studio 2012/2013 broken?带有 Visual Studio 2012/2013 的 CMake 坏了?
【发布时间】:2013-04-10 13:52:01
【问题描述】:

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

CMake 似乎添加了一些 Microsoft 编译器不再支持的设置。 LINK:致命错误 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!

【问题讨论】:

  • 我在几个项目中使用 VS2012 已经超过 1 个月了。 VTK、ITK、DCMTK、GDCM 和我的代码都构建得很好。我正在使用 CMake 2.8.10.2。虽然我很少再为 32 位构建。
  • 我在 Visual Studio 2012 中使用 CMake 已经有一段时间了,没有任何问题。前几天我重新安装了Visual Studio,安装了最新的更新,然后问题就浮出水面了。
  • 来自错误消息:找不到cl.exe(VS C++编译器)-您的cl.exe安装在哪里?尝试使用 cl 进行命令行编译(如此处所述:stackoverflow.com/questions/7865432/…)以确定您的编译器是否正常工作。也许你的 VS 安装搞砸了。
  • @Vertexwahn 您的说法不正确。找到编译器,但测试编译失败,出现 jgaa 给出的错误消息。
  • 它声明Check for working C compiler using: Visual Studio 11 -- broken 这意味着损坏。如果无法编译简单的测试代码,则认为编译器损坏。我正在使用 2.8.10.2 和 2.8.12.2 并确认 Cmake 和 VS 2012 没有问题。您可以尝试自己编译测试代码作为清单:嵌入本身并没有错。

标签: visual-studio cmake


【解决方案1】:

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 用于 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. 双击Microsoft.Cpp.Win32.user
  4. 转到 VC++ 目录
  5. 已更改的行以粗体显示。在所有粗体行上,单击内部 文本字段,然后在下拉菜单中选择 从父级继承 或项目默认值
  6. 点击应用保存,然后关闭对话框。

【讨论】:

  • 谢谢。即使我尝试编译 64 位版本,这也为我解决了 Cmake 和 Visual Studio 2013 的相同问题。
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    我也遇到了错误:

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

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

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

    总结一下:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多