CMake cl.exe is not able to compile a simple test

2019-07-10 22:37发布

问题:

This is the CMake output:

-- 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

I've checked some other questions about this and they say to downgrade to .NET 4.0 but that didn't work for me.

回答1:

In this answer: Cmake is Unable to Configure Project for Visual Studios 10 amd64

I found the solution of my problem.

For me was:

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

I have updated the compilers and now it works.



回答2:

Try to use a new cvtres.exe to replace Microsoft Visual Studio 10.0\VC\bin\cvtres.exe,I used the one from vs2012, it works! Donot forget to backup.



回答3:

In case Qt Creator 4.7.0 with CMake: I solved this problem by changing generator from 'NMake Makefiles JOM' to 'NMake Makefiles' in Tools->Options->Kits->Kits->CMake generator.