在Windows 10 x64上使用MSYS2 + MinGW将Ninja作为生成器

3

我在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 作为我的生成器吗?

2个回答

2
同样的问题
pacman -R ninja
pacman -S mingw-w64-x86_64-ninja

已解决 - 错误的忍者!

1
在我的公司,我们每天都使用mingw64 + ninja在Windows 10上工作。我不确定你的设置出了什么问题,以下是一些提示:
  • mingw64 shell而不是msys2 shell运行cmake(通常为C:/msys64/mingw64.exe
  • 确保你安装了mingw-w64-x86_64-cmake,而不仅仅是cmakemingw-w64-cmake
  • 确保你安装了mingw-w64-x86_64-ninja,而不仅仅是ninjamingw-w64-ninja
有了这两个要点,在我的Windows 10机器上,我可以成功地使用ninja进行配置和编译(尽管我们的设置有点旧,我们冻结了几年前的一个msys2版本)。

我遵循你们两个的观点。我正在使用mingw64 shell进行编译,而msys2 shell仅用于安装软件包。我已经安装了mingw-w64-x86_64-cmake——which cmake命令报告/mingw64/bin/cmake - Vittorio Romeo
嗯...我之前在同事的笔记本电脑上见过这个问题,但我不记得我们是如何解决的。明天会仔细看一下。 - sbabbi
我感觉自己像个傻瓜。我不小心安装了 mingw-w64-ninja 而不是 mingw-w64-x86_64-ninja。我很确定我已经仔细检查过了... - Vittorio Romeo
我不知道mingw-w64-xxx软件包是什么。你是指-i686吗? - sbabbi
不,你可以通过 MSYS2 shell 下载和安装 这些 - Vittorio Romeo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接