【发布时间】:2019-08-04 16:56:09
【问题描述】:
我想在我的 Windows 系统中安装协议缓冲区,同时运行以下命令:
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../../../install ../..
我收到了这个错误:
-- The C compiler identification is MSVC 19.22.27905.0
-- The CXX compiler identification is MSVC 19.22.27905.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
C 编译器:
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe"
无法编译简单的测试程序。 它失败并显示以下输出:
Change Dir: C:/ProtoBuff/protobuf-3.9.0/cmake/build/release/CMakeFiles/CMakeTmp
Run Build Command(s):nmake /nologo cmTC_5d4c2\fast && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_5d4c2.dir\build.make /nologo -L CMakeFiles\cmTC_5d4c2.dir\build
Building C object CMakeFiles/cmTC_5d4c2.dir/testCCompiler.c.obj
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1422~1.279\bin\Hostx64\x64\cl.exe @C:\Users\shubh\AppData\Local\Temp\nm4F4E.tmp
testCCompiler.c
Linking C executable cmTC_5d4c2.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_5d4c2.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1422~1.279\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_5d4c2.dir\objects1.rsp @C:\Users\shubh\AppData\Local\Temp\nm50F5.tmp
RC Pass 1: command "rc /fo CMakeFiles\cmTC_5d4c2.dir/manifest.res CMakeFiles\cmTC_5d4c2.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specifiedNMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
CMake 将无法正确生成此项目。 调用堆栈(最近的调用优先):
CMakeLists.txt:20 (project)
-- Configuring incomplete, errors occurred!
See also "C:/ProtoBuff/protobuf-3.9.0/cmake/build/release/CMakeFiles/CMakeOutput.log".
See also "C:/ProtoBuff/protobuf-3.9.0/cmake/build/release/CMakeFiles/CMakeError.log".
谁能告诉我为什么会这样?我该如何解决这个问题?
【问题讨论】:
-
我在使用 VS 16.6.3 的 Windows Server 2012 机器上构建时遇到了完全相同的问题。我使用 Ninja 作为生成器而不是 NMake。从您发布的日志中可以看出,CMake 无法找到 mt.exe (
--mt=CMAKE_MT-NOTFOUND)。从终端运行vcvarsall.bat后,运行where mt仍然找不到任何东西。可能是vcvarsall.bat脚本或VS 安装中的问题?在另一台装有 VS 16.9.5 的机器上,一切正常......