在 Windows 10 x64 上使用 Ninja 作为 MSYS2 + MinGW 的生成器
Using Ninja as a generator with MSYS2 + MinGW on Windows 10 x64
我在 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
这似乎是一个 /
与 \
的问题。
这个问题有解决方案或解决方法吗?
我可以在 Windows10 的 MSYS2 + MinGW x64 设置上使用 Ninja 作为生成器吗?
在我的公司,我们每天在 windows10 上使用 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 版本) .
同样的问题
pacman -R ninja
pacman -S mingw-w64-x86_64-ninja
已解决 - 忍者错误!
我在 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
这似乎是一个 /
与 \
的问题。
这个问题有解决方案或解决方法吗?
我可以在 Windows10 的 MSYS2 + MinGW x64 设置上使用 Ninja 作为生成器吗?
在我的公司,我们每天在 windows10 上使用 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 版本) .
同样的问题
pacman -R ninja
pacman -S mingw-w64-x86_64-ninja
已解决 - 忍者错误!