当使用Mingw64在窗口上构建cmake时,我们会得到以下错误:
System cannot find the file specified
日志:
$ cmake ..
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:72 (project):
Running
'nmake' '-?'
failed with:
The system cannot find the file specified
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "E:/MyTools/C/libs_download/cpp-httplib-0.11.2/build/CMakeFiles/CMakeOutput.log".
怎么修呢?
发布于 2022-10-10 21:23:50
这是因为cmake使用Microsoft CMake格式作为默认格式。这里的CMAKE_CXX_COMPILER not set
还指示我们需要将CMAKE_CXX_COMPILER
变量设置为c++
编译器路径。
要修复,我们需要使用以下命令:
cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CC_COMPILER=gcc -DCMAKE_MAKE_PROGRAM=mingw32-make -G "MinGW Makefiles" ..
在这里,我们提供以下标志:
CMAKE_CXX_COMPILER=g++
-使用g++
作为C++编译器(或提供完整的program-G "MinGW Makefiles"
-使用gcc
作为C compilerCMAKE_MAKE_PROGRAM=mingw32-make
-使用mingw32-make
作为make program-G "MinGW Makefiles"
-使用MinGW Makefile格式而不是Microsoft makefile format)
在此之后,您可以像往常一样运行mingw32-make
,而不是make
来构建:)
https://stackoverflow.com/questions/74020800
复制相似问题