CMake cl.exe 无法编译简单的测试程序
CMake cl.exe is not able to compile a simple test program
这是 CMake 输出:
-- The C compiler identification is MSVC 16.0.30319.1
-- The CXX compiler identification is MSVC 16.0.30319.1
-- Eclipse version is set to 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/bin/amd64/cl.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/amd64/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: E:/Code/Git/Brendan-C-SFML/build/CMakeFiles/CMakeTmp
我已经检查了一些关于此的其他问题,他们说要降级到 .NET 4.0,但这对我不起作用。
在这个回答中:Cmake is Unable to Configure Project for Visual Studios 10 amd64
我找到了问题的解决方案。
对我来说是:
I found that my x64 compilers were destroyed by installing SP 1. Try this update to restore them: http://www.microsoft.com/en-us/download/details.aspx?id=4422
我已经更新了编译器,现在它可以工作了。
尝试用新的cvtres.exe替换Microsoft Visual Studio 10.0\VC\bin\cvtres.exe,我用的是vs2012的,可以!不要忘记备份。
如果 Qt Creator 4.7.0 带有 CMake:
我通过在 Tools->Options->Kits->Kits->CMake generator.
中将生成器从 'NMake Makefiles JOM' 更改为 'NMake Makefiles' 解决了这个问题。
我在 Visual Studio 2019(Windows 10)遇到了类似的问题。
我搜索了它,这是唯一一个(在标题中)与我从 Visual Studio 得到的输出相似的 Whosebug 问题。我不确定我是否应该创建一个问题来自己回答,所以遇到同样问题的人可能会找到这个解决方案。这就是为什么我把它写在这里。
无论如何,保存 CMake“项目”(由 Visual Studio 创建)并重新启动程序解决了问题。
如果您在 MSVC 中使用 qt,请不要忘记安装 cdb。
这是 CMake 输出:
-- The C compiler identification is MSVC 16.0.30319.1
-- The CXX compiler identification is MSVC 16.0.30319.1
-- Eclipse version is set to 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10.0/VC/bin/amd64/cl.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/amd64/cl.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: E:/Code/Git/Brendan-C-SFML/build/CMakeFiles/CMakeTmp
我已经检查了一些关于此的其他问题,他们说要降级到 .NET 4.0,但这对我不起作用。
在这个回答中:Cmake is Unable to Configure Project for Visual Studios 10 amd64
我找到了问题的解决方案。
对我来说是:
I found that my x64 compilers were destroyed by installing SP 1. Try this update to restore them: http://www.microsoft.com/en-us/download/details.aspx?id=4422
我已经更新了编译器,现在它可以工作了。
尝试用新的cvtres.exe替换Microsoft Visual Studio 10.0\VC\bin\cvtres.exe,我用的是vs2012的,可以!不要忘记备份。
如果 Qt Creator 4.7.0 带有 CMake: 我通过在 Tools->Options->Kits->Kits->CMake generator.
中将生成器从 'NMake Makefiles JOM' 更改为 'NMake Makefiles' 解决了这个问题。我在 Visual Studio 2019(Windows 10)遇到了类似的问题。
我搜索了它,这是唯一一个(在标题中)与我从 Visual Studio 得到的输出相似的 Whosebug 问题。我不确定我是否应该创建一个问题来自己回答,所以遇到同样问题的人可能会找到这个解决方案。这就是为什么我把它写在这里。
无论如何,保存 CMake“项目”(由 Visual Studio 创建)并重新启动程序解决了问题。
如果您在 MSVC 中使用 qt,请不要忘记安装 cdb。