【问题标题】:CMake Error : execution of make failed on WindowsCMake 错误:在 Windows 上执行 make 失败
【发布时间】:2018-03-30 04:25:48
【问题描述】:

尝试在 Windows 7 中构建 nanomsg project 时遇到错误:

cmake ..
-- Building for: NMake Makefiles
-- The C compiler identification is GNU 4.7.1
-- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_5d837\fast"
-- Check for working C compiler: C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/cmake-3.9.4-win64-x64/share/cmake-3.9/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler "C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe" is not
able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeTmp



Run Build Command:"nmake" "/NOLOGO" "cmTC_5d837\fast"



Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"
"cmTC_5d837\fast"





CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:29 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/User/Documents/Internal/nanomsg-master/build/CMakeFiles/CMakeError.log".

我使用gcc编译器和Mingw工具链中的make,我可以在一个简单的例子中成功运行gcc.exe和mingw32-make.exe。

在CMakeCache.txt文件中缓存变量设置如下:

//C compiler
CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/CodeBlocks/MinGW/bin/gcc.exe

//Program used to build from makefiles.
CMAKE_MAKE_PROGRAM:STRING=nmake

我认为问题来自CMAKE_MAKE_PROGRAM 变量,它应该采用C:/Program Files (x86)/CodeBlocks/MinGW/bin/mingw32-make.exe,但是我不明白它从哪里获得值nmake。

即使我手动更换它,我也会遇到同样的问题。

我的问题:

  • CMake 如何填充缓存变量?
  • 为什么CMAKE_MAKE_PROGRAM 取值nmake?
  • 为什么手动更改此变量不能解决问题?

【问题讨论】:

  • CMake Error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found 的可能重复项。您需要在 CMake 命令行中指定一个生成器,例如 -G "MinGW Makefiles" 并且 - 根据您安装的编译器数量 - 还有编译器的完整路径。
  • @Florian,感谢您的反馈,可以解决问题:)。当我更改生成器时发生了什么,CMake 有内部脚本,可以搜索 c 编译器和 make 程序,然后更新缓存变量,因为现在我可以看到 CMakeCache.txt 中的变量具有良好的值
  • @Mouin - nmake 是微软的制作工具。您可以从Visual C++ 2015 Build Tools 获取它的副本。您不再需要下载 Visual Studio 或处理即将到期的试用版。构建工具是 Visual Studio 工具的子集,它包括编译器、链接器、nmake 和一些其他 Windows 基本工具。

标签: cmake mingw nanomsg


【解决方案1】:

CMake 使用它根据CMakeLists.txt 中的内容以及它包含的任何文件以及提供给cmake 的任何-D 参数检测到的值填充缓存文件。

在 Windows 上,CMake 将默认使用 Microsoft 的 nmake 工具。覆盖它的方法是将参数-G"MinGW Makefiles" 传递给cmake,或者如果您使用MSYS shell -G"MSYS Makefiles"。

但是有比make´ called Ninja (get it from https://ninja-build.org/) which you can use by passing -GNinjatocmake`更快的构建工具。

注意:我看到您使用的是 Code::Blocks 附带的旧 MinGW。 MinGW 有一个更新的后续版本,称为 MinGW-w64,它支持 Windows 32 位和 64 位。最近的独立版本可以从https://winlibs.com/ 下载,它还包括ninja.exe。

P.S.:如果您在按照这些提示构建 nanomsg 源代码时遇到更多问题,请考虑将 -DNN_TESTS:BOOL=OFF 传递给 cmake

【讨论】:

    猜你喜欢
    • 2021-03-16
    • 2013-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多