Linux开发环境搭建之cmake编译错误

Linux系统使用cmake命令时发现,虽然cmake --version获取版本成功了,但是使命命令时还是出现了错误,比如:

No CMAKE_CXX_COMPILER could be found.

$ cmake . -- The C compiler identification is GNU 9.3.0 -- The CXX compiler identification is unknown -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done 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! See also "/mnt/d/code/cmake/CMakeFiles/CMakeOutput.log". See also "/mnt/d/code/cmake/CMakeFiles/CMakeError.log".

解决方法如下:

sudo apt-get update
sudo apt-get install -y build-essential
经验分享 程序员 微信小程序 职场和发展