gpt4 book ai didi

visual-studio - 带有 Visual Studio 2012/2013 的 CMake 损坏了吗?

转载 作者:行者123 更新时间:2023-12-01 01:49:55 41 4
gpt4 key购买 nike

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

似乎 CMake 添加了一些 Microsoft 编译器不再支持的设置。 LINK: fatal error LNK1117:选项“ list :嵌入”中的语法错误

我用一个非常基本的 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!

最佳答案

CMake 2.8 与 Visual Studio 2012 配合良好。

在您提供的日志中,请注意 CMake 调用 Visual Studio 2012,后者又调用Visual Studio 2008 的编译器(15.x;VS2012 的编译器应为 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

这可能意味着您安装的 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. 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.

关于visual-studio - 带有 Visual Studio 2012/2013 的 CMake 损坏了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15927803/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com