windows - CMake 将无法正确生成该项目。调用堆栈(最近调用最先): CMakeLists. txt:20(项目)

标签 windows cmake

我想在运行以下命令时在我的 Windows 系统中安装 Protocol Buffer :

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

有人能告诉我为什么会这样吗?我该如何解决这个问题?

最佳答案

我在 Windows 10 上使用 msys2 构建 gvsbuild 时遇到了类似的问题。

我通过将 mt.exe 和 mt.exe.config 这两个文件从“C:\Program Files (x86)\Windows Kits\8.1\bin\x86”复制到“C:\Program Files (x86)”来修复它\Microsoft Visual Studio 14.0\VC\bin".您可以根据您的编译器版本调整这些目录。

这类似于 Visual Studio can't build due to rc.exe

关于windows - CMake 将无法正确生成该项目。调用堆栈(最近调用最先): CMakeLists. txt:20(项目),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57348542/

相关文章:

python - 无法安装skbuild

c++ - Cmake 生成的 Eclipse 项目 - 无源

cmake - 如何表示映射文件依赖于 add_executable?

c# - 基于64位或32位操作系统导入外部dll

cmake - 在 FindXXX.cmake 的 XXX_INCLUDE_DIRS 或 XXX_LIBRARIES 中指定多个路径

windows - 升级到1.14.0后缺少TortoiseSVN上下文菜单

c++ - 用于解压缩受密码保护的文件的库

c - 让编译器找到 Cmake 创建的文件

windows - C++11 std::cout << "string literal in UTF-8"到 Windows cmd 控制台? ( Visual Studio 2015)

windows - 使用 Run() 启动的程序无法找到其配置文件