如何解决在 Windows 10 x64
我在 Windows 上使用 MSYS2 + MinGW x64 + CMake 作为我的开发设置。目前,为了初始化我的项目,我打开一个 “MSYS2 MinGW 64 位” shell 并调用 CMake,如下所示:
cmake .. -G"MinGW Makefiles"
这很好用,但我想使用 ninja
而不是 make
。因此,我通过 MSYS2 shell 安装了 mingw-w64-x86_64-ninja
,使其在我的 MinGW 环境中可用。我期待
cmake .. -G"Ninja"
工作,但它失败并出现以下错误:
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - broken
CMake Error at C:/msys64/mingw64/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/msys64/mingw64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/projecct/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/msys64/usr/bin/ninja.exe cmTC_c3f3d && [1/2] Building C object CMakeFiles/cmTC_c3f3d.dir/testCCompiler.c.obj
FAILED: CMakeFiles/cmTC_c3f3d.dir/testCCompiler.c.obj
C:\msys64\mingw64\bin\gcc.exe -o CMakeFiles/cmTC_c3f3d.dir/testCCompiler.c.obj -c testCCompiler.c
/bin/sh: line 1: C:msys64mingw64bingcc.exe: command not found
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete,errors occurred!
See also "C:/project/build/CMakeFiles/CMakeOutput.log".
See also "C:/project/build/CMakeFiles/CMakeError.log".
从下面一行判断
/bin/sh: line 1: C:msys64mingw64bingcc.exe: command not found
这似乎是 /
与 \
的问题。
-
这个问题有解决方案吗?
-
我可以在 Windows 10 上的 MSYS2 + MinGW x64 设置中使用 Ninja 作为我的生成器吗?
解决方法
在我的公司,我们每天在 Windows 10 上使用 mingw64 + ninja。我不确定您的设置出了什么问题,以下是一些提示:
- 从 mingw64 shell 运行 cmake,而不是 msys2 shell(通常是
C:/msys64/mingw64.exe
) - 确保您安装了
mingw-w64-x86_64-cmake
,而不仅仅是cmake
或mingw-w64-cmake
。 - 确保您安装了
mingw-w64-x86_64-ninja
,而不仅仅是ninja
或mingw-w64-ninja
。
考虑到这 2 项,在我的 Windows 10 机器上,我可以成功地使用 ninja 进行配置和编译(假设我们的设置有点旧,我们冻结了几年前的 msys2 版本)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。