在Windows7中构建纳米工程时,我遇到了错误:
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_MAKE_PROGRAM
取值nmake
?发布于 2021-06-29 08:35:11
CMake在缓存文件中填充它所检测到的值,这些值基于CMakeLists.txt
中的内容以及它所包含的任何文件,以及提供给cmake
的任何-D
参数。
在Windows上,CMake默认为微软的nmake
工具。重写此操作的方法是将参数-G"MinGW Makefiles"
传递给cmake
,或者在您使用MSYS -G"MSYS Makefiles"
的情况下。
但是有一个比make
更快的构建工具Ninja (从https://ninja-build.org/获得它),您可以通过将-GNinja
传递给cmake
来使用它。
注意:我看到您使用的是代码::块附带的旧MinGW。有一个更最新的后继MinGW称为MinGW-w64,它既支持32位,也支持64位。最近的独立构建可以从https://winlibs.com/下载,它还包括ninja.exe
。
P.S.:如果在遵循这些技巧之后构建nanomsg源时遇到更多问题,请考虑将-DNN_TESTS:BOOL=OFF
传递给cmake
。
https://stackoverflow.com/questions/46807753
复制相似问题