Reputation: 89
I want to install protocol buffers in my Windows system while running below command:
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../../../install ../..
I got this error:
-- 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):
The C compiler:
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program. It fails with the following output:
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 will not be able to correctly generate this project. Call Stack (most recent call first):
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".
Can anybody suggest me why it's happening? How do I fix this?
Upvotes: 5
Views: 8441
Reputation: 283
This is caused because a newer Visual Studio was additionally installed on the computer. Running the following command solved the issue for me.
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 8.1
Similar to: Visual Studio can't build due to rc.exe
Upvotes: 1
Reputation: 109
I had a similar problem when building gvsbuild with msys2 on Windows 10.
I fixed it by copying the two files mt.exe and mt.exe.config from "C:\Program Files (x86)\Windows Kits\8.1\bin\x86" to "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" . You might adapt these directories to your compiler version.
This is similar to Visual Studio can't build due to rc.exe
Upvotes: 1
Reputation: 303
I'm having the exact same issue while building on a Windows Server 2012 machine with VS 16.6.3, through an automated TFS build agent. I'm using Ninja as a generator instead of NMake.
TL;DR: check that the user account that is performing the build has the privileges to query the Windows registry.
The detailed answer:
From the log you posted, I can spot that CMake isn't able to find mt.exe
(check the --mt=CMAKE_MT-NOTFOUND
option passed to the linker). I'm having the same problem: CMake can't find mt.exe
.
How are you preparing your command line? I suppose that you are running vcvarsall.bat
(or equivalent) like me. If I open a command line, run the vcvarsall.bat
script and then run where mt
, I get no result. This means that the script wasn't able to setup the environment correctly, and, ultimately, causes CMake to fail with that error.
Thanks to this answer, I found out that one can increase the verbosity of the vcvarsall.bat
script. So I run
set VSCMD_DEBUG=3
vcvarsall.bat > out.txt
to find out that I had a lot of
ERROR: Registry editing has been disabled by your administrator.
Digging into the vcvarsall.bat
and its nested scripts, I found many calls to reg query <key>
in the section related to the detection of the Windows 10 SDK. On another functioning machine, the mt.exe
is located into
C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\mt.exe
If I double-check by running the same reg query <key>
command from a clean command line (with the same user that runs the build) I get the same error of the vcvarsall.bat
script.
By adding the proper privileges to the user that runs the build I managed to solve the issue.
Upvotes: 0