【问题标题】:Using Ninja as a generator with MSYS2 + MinGW on Windows 10 x64在 Windows 10 x64 上使用 Ninja 作为带有 MSYS2 + MinGW 的生成器
【发布时间】:2021-07-20 05:11:46
【问题描述】:

我在 Windows 上使用 MSYS2 + MinGW x64 + CMake 作为我的开发设置。目前,为了初始化我的项目,我打开一个 "MSYS2 MinGW 64-bit" 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 作为我的生成器吗?

【问题讨论】:

    标签: c++ windows cmake mingw ninja


    【解决方案1】:

    在我的公司,我们每天在 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。

    考虑到这两点,在我的 windows 10 机器上,我可以成功地配置和编译 ninja(假设我们的设置有点旧,我们冻结了几年前的 msys2 版本)。

    【讨论】:

    • 我正在关注您的两点。我使用mingw64 shell 进行编译,msys2 shell 仅用于安装包。我已经安装了mingw-w64-x86_64-cmake -- which cmake 命令报告/mingw64/bin/cmake。
    • 嗯...我以前在同事的笔记本电脑上看到过这个问题,但我不记得我们是如何解决的。明天会更好看
    • 我觉得自己像个笨蛋。我不小心安装了mingw-w64-ninja 而不是mingw-w64-x86_64-ninja。我很确定我仔细检查了...
    • 我不知道mingw-w64-xxx 包是什么。你的意思是-i686?
    • 不,您可以通过 MSYS2 shell 下载并安装these。
    【解决方案2】:

    同样的问题

    pacman -R ninja
    pacman -S mingw-w64-x86_64-ninja
    

    已解决 - 忍者错误!

    【讨论】:

      猜你喜欢
      • 2016-10-29
      • 2017-06-22
      • 2015-09-24
      • 1970-01-01
      • 2016-07-14
      • 2016-03-14
      • 1970-01-01
      • 2016-07-25
      • 1970-01-01
      相关资源
      最近更新 更多