我在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 作为我的生成器吗?
mingw64
shell进行编译,而msys2
shell仅用于安装软件包。我已经安装了mingw-w64-x86_64-cmake
——which cmake
命令报告/mingw64/bin/cmake
。 - Vittorio Romeomingw-w64-ninja
而不是mingw-w64-x86_64-ninja
。我很确定我已经仔细检查过了... - Vittorio Romeomingw-w64-xxx
软件包是什么。你是指-i686
吗? - sbabbi