CMake Error at CMakeLists.txt:5 (PROJECT): The CMAKE_C_COMPILER: cl is not a full path

川长思鸟来 2022-02-18 09:57 2017阅读 1赞

报错:

- 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:

  1. 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:

  1. 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.

-- Configuring incomplete, errors occurred!
See also “E:/gc/c_test1/build/CMakeFiles/CMakeOutput.log”.
See also “E:/gc/c_test1/build/CMakeFiles/CMakeError.log”.

解答:

1.不用cmake.. 用下面的命令

  1. cmake -G "MSYS Makefiles" ..

2.如果第一个不行,那么设置路径:

  1. $ export CC=/c/MinGW/bin/gcc.exe
  2. $ export CXX=/c/MinGW/bin/g++.exe
  3. $ cmake -G "MinGW Makefiles" ..
  4. -- The CXX compiler identification is GNU 4.8.1
  5. ...
  6. $ mingw32-make

第2种:

  1. $ cmake -DCMAKE_C_COMPILER=/c/MinGW/bin/gcc.exe -DCMAKE_CXX_COMPILER=/c/MinGW/bin/g++.exe ..

如果还不行,参考下面链接:

https://www.e-learn.cn/content/wangluowenzhang/22835

https://stackoverflow.com/questions/29746950/cmake-cannot-find-compiler

发表评论

表情:
评论列表 (有 0 条评论,2017人围观)

还没有评论,来说两句吧...

相关阅读