CMake和Visual studio 2015 - C编译器cl.exe无法编译简单的测试程序

时间:2017-07-19 14:11:02

标签: c++ visual-studio-2015 cmake

我正在尝试使用microsoft visual studio 2015与Qt创建者上的cmake结合编译我的程序,我得到这个错误,我真的不知道如何解决。

Running "C:\Program Files\CMake\bin\cmake.exe C:/Users/SEVLH/Documents/sodis"-GCodeBlocks - NMake Makefiles" "-DCMAKE_CXX_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe" "-DCMAKE_C_COMPILER:STRING=C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe" "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/Qt5.8.0/5.8/msvc2015_64" "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/Qt5.8.0/5.8/msvc2015_64/bin/qmake.exe"" in C:\Users\SEVLH\AppData\Local\Temp\qtc-cmake-Yu2EZw.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe" is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/SEVLH/AppData/Local/Temp/qtc-cmake-Yu2EZw/CMakeFiles/CMakeTmp



Run Build Command:"nmake" "/NOLOGO" "cmTC_eda15\fast"

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\nmake.exe" -f CMakeFiles\cmTC_eda15.dir\build.make 
/nologo -L CMakeFiles\cmTC_eda15.dir\build

Building C object CMakeFiles/cmTC_eda15.dir/testCCompiler.c.obj

C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe -o
CMakeFiles\cmTC_eda15.dir\testCCompiler.c.obj -c
C:\Users\SEVLH\AppData\Local\Temp\qtc-cmake-Yu2EZw\CMakeFiles\CMakeTmp\testCCompiler.c


NMAKE : fatal error U1045: spawn failed : Invalid argument

 Stop.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\nmake.exe"' : return code '0x2'

 Stop.





CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)

2 个答案:

答案 0 :(得分:0)

我解决了将jom.exe添加到路径

的问题

答案 1 :(得分:0)

我通过在工具>选项>套件中将CMake生成器更改为Ninja解决了Visual Studio 2019和QT 5.14.1(Qt Creator 4.11.0)的问题。