cl.exe无法编译简单的测试程序VS2017 我试图用CMake(我使用Windows 10 X64)编译VS2017上的C++项目。 这是我的任务。json: { "version": "2.0.0", "tasks": [ { "label": "CMake Debug", "type": "shell", "options": { "cwd": "${workspaceRoot}/build" }, "command": "CMake", "args": [ "-G", "NMake Makefiles", "-DCMAKE_BUILD_TYPE=Debug", ".." ], "problemMatcher": [ "$gcc" ] }, { "label": "Make", "type": "shell", "options": { "cwd": "${workspaceRoot}/build" }, "command": "nmake", "group": { "kind": "build", "isDefault": true } } ]

cl.exe无法编译简单的测试程序VS2017 我试图用CMake(我使用Windows 10 X64)编译VS2017上的C++项目。 这是我的任务。json: { "version": "2.0.0", "tasks": [ { "label": "CMake Debug", "type": "shell", "options": { "cwd": "${workspaceRoot}/build" }, "command": "CMake", "args": [ "-G", "NMake Makefiles", "-DCMAKE_BUILD_TYPE=Debug", ".." ], "problemMatcher": [ "$gcc" ] }, { "label": "Make", "type": "shell", "options": { "cwd": "${workspaceRoot}/build" }, "command": "nmake", "group": { "kind": "build", "isDefault": true } } ],c++,cmake,visual-studio-2017,cl.exe,C++,Cmake,Visual Studio 2017,Cl.exe,} 当我运行CMake调试任务时,出现以下错误: Executing task: CMake -G 'NMake Makefiles' -DCMAKE_BUILD_TYPE=Debug .. < -- The C compiler identification is unknown -- The CXX compiler identification is unknown -- Check for working C compiler: C:/Program Files (x86)/Mi

}

当我运行CMake调试任务时,出现以下错误:

Executing task: CMake -G 'NMake Makefiles' -DCMAKE_BUILD_TYPE=Debug .. <

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/Paul/Desktop/EIP/Cryptagora-prisma/monitoring_tool/build/CMakeFiles/CMakeTmp

    Run Build Command:"nmake" "/nologo" "cmTC_8304c\fast"
        "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_8304c.dir\build.make /nologo -L                  CMakeFiles\cmTC_8304c.dir\build
    Building C object CMakeFiles/cmTC_8304c.dir/testCCompiler.c.obj
        C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x86\cl.exe    -o CMakeFiles\cmTC_8304c.dir\testCCompiler.c.obj   -c C:\Users\Paul\Desktop\EIP\Cryptagora-prisma\monitoring_tool\build\CMakeFiles\CMakeTmp\testCCompiler.c
    NMAKE : fatal error U1045: Úchec de la gÚnÚration dynamiqueá: Invalid argument
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"'á: code retour '0x2'
    Stop.




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


-- Configuring incomplete, errors occurred!
See also "C:/Users/Paul/Desktop/EIP/Cryptagora-prisma/monitoring_tool/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Paul/Desktop/EIP/Cryptagora-prisma/monitoring_tool/build/CMakeFiles/CMakeError.log".
The terminal process terminated with exit code: 1
执行任务:CMake-G'NMake makefile'-DCMAKE\u BUILD\u TYPE=Debug<
--C编译器标识未知
--CXX编译器标识未知
--检查C编译器是否工作:C:/Program Files(x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe
--检查C编译器是否工作:C:/Program Files(x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe--已损坏
C:/Program Files/CMake/share/CMake-3.12/Modules/CmaketTestCcompiler处的CMake错误。CMake:52(消息):
C编译器
“C:/ProgramFiles(x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe”
无法编译简单的测试程序。
它失败,输出如下:
更改目录:C:/Users/Paul/Desktop/EIP/Cryptagora-prisma/monitoring\u-tool/build/CMakeFiles/CMakeTmp
运行生成命令:“nmake”“/nologo”“cmTC_8304c\fast”
“C:\Program Files(x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe”-f CMakeFiles\cmTC_8304c.dir\build.make/nologo-L CMakeFiles\cmTC_8304c.dir\build
构建C对象cmakfiles/cmTC_8304c.dir/testCCompiler.C.obj
C:\PROGRA~2\MICROS~2\2017\common~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x86\cl.exe-o CMakeFiles\cmTC_8304; 4c.dir\testCCompiler.C.obj-C:\Users\Paul\Desktop\EIP\Cryptagora prisma\monitoring\tool\build\CMakeFiles\cmakemp\testCCompiler.C
NMAKE:致命错误U1045:Úchec de la gÚnÚration dynamiqueá:无效参数
停止
NMAKE:致命错误U1077:“'C:\Program Files(x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\NMAKE.exe”'á:代码检索'0x2'
停止
CMake将无法正确生成此项目。
调用堆栈(最新调用优先):
CMakeLists.txt:3(项目)
--配置不完整,出现错误!
另请参见“C:/Users/Paul/Desktop/EIP/Cryptagora prisma/monitoring_tool/build/CMakeFiles/CMakeOutput.log”。
另请参见“C:/Users/Paul/Desktop/EIP/Cryptagora prisma/monitoring_tool/build/CMakeFiles/CMakeError.log”。
终端进程终止,退出代码为:1

昨天这个工作做得很好

几个月前我就遇到了这个问题,不得不恢复到旧版本的cmake。特别是降级到3.12.4。

如果您在windows上开发,如果您完全避免使用cmake,您将有一个更加流畅的体验。请以文本形式粘贴日志,而不是以图像形式粘贴日志。这是堆栈溢出的要求。为什么要在windows上避免CMake?我还可以使用什么?尝试使用开发人员命令提示符,而不是普通的命令提示符?您可以只使用普通的旧visual studio。原因是你引入了一个巨大的中间层,这是完全不必要的。第二,仅仅是你在这里发布的问题。