Visual c++ CMake cl.exe无法编译简单的测试程序

Visual c++ CMake cl.exe无法编译简单的测试程序,visual-c++,cmake,Visual C++,Cmake,这是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:/Pro

这是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,但这对我不起作用。

在这个答案中:

我找到了问题的解决办法

对我来说:

我发现我的x64编译器在安装SP 1时被破坏。尝试此更新以还原它们:


我已经更新了编译器,现在它可以工作了。

尝试使用新的cvtres.exe替换Microsoft Visual Studio 10.0\VC\bin\cvtres.exe,我使用了vs2012中的一个,它可以工作!不要忘记备份。

如果使用CMake的Qt Creator 4.7.0:
我通过在工具->选项->工具包->工具包->CMake生成器中将生成器从“NMake Makefiles JOM”更改为“NMake Makefiles”,解决了这个问题。

我在Visual Studio 2019(在Windows 10上)中遇到了类似的问题

我搜索了它,这是唯一一个(标题中)与我从VisualStudio获得的输出类似的stackoverflow问题。我不确定我是否应该自己创建一个问题来回答它,所以遇到相同问题的人可能会找到这个解决方案。这就是为什么我要把它写在这里


无论如何,保存CMake“项目”(由Visual Studio创建)并重新启动程序解决了问题。

您是否在64位OSTry上,从命令提示符(而不是从CMake内部)运行
cl.exe
,并查看它是否会给您任何其他错误消息是的,我在64位Win7上。否则cl.exe可以正常工作。忘了提到我只安装了Win7 SDK,没有Visual Studio。可能是