mingw下的cmake有什么问题

时间:2019-03-11 00:10:26

标签: windows cmake mingw

mkdir build
cd build
cmake -G "MinGW Makefiles" ..
CMake Error at I:/msys64/mingw32/share/cmake-3.13/Modules/CMakeMinGWFindMake.cmake:12 (message):
  sh.exe was found in your PATH, here:

  I:/msys64/usr/bin/sh.exe

  For MinGW make to work correctly sh.exe must NOT be in your path.

  Run cmake from a shell that does not have sh.exe in your PATH.

  If you want to use a UNIX shell, then use MSYS Makefiles.

Call Stack (most recent call first):
  CMakeLists.txt:16 (PROJECT)


CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

但看起来令人反感的sh.exe是msys的一部分?

好的,所以尝试使用msys shell ... i:\msys64\mingw32

rm -rf build
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
CMake Error at I:/msys64/mingw32/share/cmake-3.13/Modules/CMakeMinGWFindMake.cmake:12 (message):
  sh.exe was found in your PATH, here:

  I:/msys64/usr/bin/sh.exe

  For MinGW make to work correctly sh.exe must NOT be in your path.

  Run cmake from a shell that does not have sh.exe in your PATH.

  If you want to use a UNIX shell, then use MSYS Makefiles.

Call Stack (most recent call first):
  CMakeLists.txt:16 (PROJECT)


CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

同一件事。

sh.exe应该在那里吗?

最后一次尝试...

cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..

$ cmake -G "MinGW Makefiles" -DCMAKE_SH="CMAKE_SH-NOTFOUND" ..
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

所以似乎还有第二个问题?

有什么帮助吗?谢谢。

1 个答案:

答案 0 :(得分:0)

首先,请确保您已安装mingw32-make

which mingw32-make

如果不是/mingw64/bin/mingw32-make,则说明该路径不在您的~/.bashrc中或未安装。我想您可以通过以下方式安装它:

pacman -S mingw64/mingw-w64-x86_64-make

这也是您可能已经安装的mingw-w64-x86_64-toolchain的一部分。那么您应该可以运行

cmake -D CMAKE_MAKE_PROGRAM:PATH=/mingw64/bin/mingw32-make

请尝试一下,让我知道这是否适合您。