NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
http://lordleid.lofter.com/post/7546f_aeff74a ## [阿英讲Cmake msys32使用问题解答 CXX CMAKE\_C\_COMPILER配置详解](http://lordleid.lofter.com/post/7546f_aeff74a) **即以此功德,庄严佛净土。上报四重恩,下济三途苦。惟愿见闻者,悉发菩提心。在世富贵全,往生极乐国。** 缘起:笔者也是初学者,对于碰到的问题花了整整一个晚上查资料,到现在才调试通过。将遇见的问题和解决方案分享给大家,希望后来的初学者受益!南无阿弥陀佛! (1)问题1:cl is not a full path and was not found in the PATH  cmake . \-- Building for: NMake Makefiles \-- The C compiler identification is unknown \-- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:5 (project):   The CMAKE\_C\_COMPILER:     cl   is not a full path and was not found in the PATH.   To use the NMake generator with Visual C++, cmake must be run from a shell   that can use the compiler cl from the command line.  This environment is   unable to invoke the cl compiler.  To fix this problem, run cmake from the   Visual Studio Command Prompt (vcvarsall.bat).   Tell CMake where to find the compiler by setting either the environment   variable "CC" or the CMake cache entry CMAKE\_C\_COMPILER to the full path to   the compiler, or to the compiler name if it is in the PATH. CMake Error at CMakeLists.txt:5 (project):   The CMAKE\_CXX\_COMPILER:     cl   is not a full path and was not found in the PATH.   To use the NMake generator with Visual C++, cmake must be run from a shell   that can use the compiler cl from the command line.  This environment is   unable to invoke the cl compiler.  To fix this problem, run cmake from the   Visual Studio Command Prompt (vcvarsall.bat).   Tell CMake where to find the compiler by setting either the environment   variable "CXX" or the CMake cache entry CMAKE\_CXX\_COMPILER to the full path   to the compiler, or to the compiler name if it is in the PATH. 解决方法:注意gcc.exe一定要带上exe文件名! **export CC="/d/msys32/mingw32/bin/gcc.exe"       ** **export CXX="/d/msys32/mingw32/bin/g++.exe"** **cmake /path/to/your/project** (2)问题2 $ cmake . \-- Building for: NMake Makefiles \-- The C compiler identification is GNU 5.3.0 \-- The CXX compiler identification is GNU 5.3.0 \-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC\_409d1\\fast" \-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe -- broken CMake Error at D:/msys32/mingw32/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (message):   The C compiler "D:/msys32/mingw32/bin/gcc.exe" is not able to compile a   simple test program.   It fails with the following output:    Change Dir: D:/msys32/home/Demo1/CMakeFiles/CMakeTmp   Run Build Command:"nmake" "/NOLOGO" "cmTC\_409d1\\fast"   系统找不到指定的文件。   Generator: execution of make failed.  Make command was: "nmake" "/NOLOGO"   "cmTC\_409d1\\fast" 解决方法: **cmake . -G"MSYS Makefiles"** **(3) 运行结果** $ cmake . -G"MSYS Makefiles" \-- The C compiler identification is GNU 5.3.0 \-- The CXX compiler identification is GNU 5.3.0 \-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe \-- Check for working C compiler: D:/msys32/mingw32/bin/gcc.exe -- works \-- Detecting C compiler ABI info \-- Detecting C compiler ABI info - done \-- Detecting C compile features \-- Detecting C compile features - done \-- Check for working CXX compiler: D:/msys32/mingw32/bin/g++.exe \-- Check for working CXX compiler: D:/msys32/mingw32/bin/g++.exe -- works \-- Detecting CXX compiler ABI info \-- Detecting CXX compiler ABI info - done \-- Detecting CXX compile features \-- Detecting CXX compile features - done \-- Configuring done \-- Generating done \-- Build files have been written to: D:/msys32/home/Demo2 **$ make** **Scanning dependencies of target Demo** **\[ 33%\] Building CXX object CMakeFiles/Demo.dir/main.cc.obj** **\[ 66%\] Building CXX object CMakeFiles/Demo.dir/MathFunctions.cc.obj** **\[100%\] Linking CXX executable Demo.exe** **\[100%\] Built target Demo** **$ ./demo 3 3** **3 ^ 3 is 27** ![阿英讲Cmake msys32使用问题解答 CXX CMAKE_C_COMPILER配置详解 - 阿英 - Mr.Right](http://img2.ph.126.net/xilNYR4E1q8eG1b3VA1C-A==/4831236500362361981.jpg "阿英讲Cmake msys32使用问题解答 CXX CMAKE_C_COMPILER配置详解 - 阿英 - Mr.Right")