在终端输入cmake ..
的时候,报错如下:
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_CXX_COMPILER could be found.
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!
原因是没有安装gcc和g++编译环境。安装方法很简单,一行命令搞定。在终端输入sudo apt-get install build-essential
进行安装即可。为了查看是否安装上了,可以依次输入gcc --version
、g++ --version
来查看安装的gcc和g++的版本号。如果输出如下信息,则表明安装成功:
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
安装成功后,需要重启刚终端,然后再次输入cmake ..
即可生成make文件。