Ubuntu cmake error: No CMAKE_CXX_COMPILER could be found


Error: No CMAKE_CXX_COMPILER could be found.

root@tutorialspots:~/lua-mongo# cmake .
-- The C compiler identification is GNU 9.4.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:2 (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 "/root/lua-mongo/CMakeFiles/CMakeOutput.log".
See also "/root/lua-mongo/CMakeFiles/CMakeError.log".

Solution:

Install g++

apt-get install g++

root@tutorialspots:~/lua-mongo# apt-get install g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libsasl2-dev libsnappy-dev
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  g++-9 libstdc++-9-dev
Suggested packages:
  g++-multilib g++-9-multilib gcc-9-doc libstdc++-9-doc
The following NEW packages will be installed:
  g++ g++-9 libstdc++-9-dev
0 upgraded, 3 newly installed, 0 to remove and 45 not upgraded.
Need to get 10.1 MB of archives.
After this operation, 46.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://mirror.hetzner.com/ubuntu/packages focal-updates/main amd64 libstdc++-9-dev amd64 9.4.0-1ubuntu1~20.04.1 [1,722 kB]
Get:2 https://mirror.hetzner.com/ubuntu/packages focal-updates/main amd64 g++-9 amd64 9.4.0-1ubuntu1~20.04.1 [8,420 kB]
Get:3 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 g++ amd64 4:9.3.0-1ubuntu2 [1,604 B]
Fetched 10.1 MB in 0s (66.8 MB/s)
Selecting previously unselected package libstdc++-9-dev:amd64.
(Reading database ... 51398 files and directories currently installed.)
Preparing to unpack .../libstdc++-9-dev_9.4.0-1ubuntu1~20.04.1_amd64.deb ...
Unpacking libstdc++-9-dev:amd64 (9.4.0-1ubuntu1~20.04.1) ...
Selecting previously unselected package g++-9.
Preparing to unpack .../g++-9_9.4.0-1ubuntu1~20.04.1_amd64.deb ...
Unpacking g++-9 (9.4.0-1ubuntu1~20.04.1) ...
Selecting previously unselected package g++.
Preparing to unpack .../g++_4%3a9.3.0-1ubuntu2_amd64.deb ...
Unpacking g++ (4:9.3.0-1ubuntu2) ...
Setting up libstdc++-9-dev:amd64 (9.4.0-1ubuntu1~20.04.1) ...
Setting up g++-9 (9.4.0-1ubuntu1~20.04.1) ...
Setting up g++ (4:9.3.0-1ubuntu2) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Processing triggers for man-db (2.9.1-1) ...

Leave a Reply