• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CMAKE_CXX_COMPILER could be found in Ubuntu

by admin

If you are seeing an error message that says “CMAKE_CXX_COMPILER could not be found” when trying to build a C++ project on Ubuntu 22.04, it means that the C++ compiler is not installed or is not in the system’s PATH environment variable.

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.

The The “compiler” is a separate package that needs to be installed in your machine, g++ and build-essential.

$ sudo apt-get install g++
$ sudo apt-get install build-essential

This will install the GNU C++ compiler (g++) along with any necessary dependencies. Once the installation is complete, you should be able to run the C++ compiler and the “whereis g++” command should show its location.

If the compiler is already installed and you’re still getting the error, it could be that the C++ compiler binary is not in your system’s PATH environment variable. You can check if the C++ compiler binary is in your system’s PATH by running the following command:

$ echo $PATH

This will display a list of directories separated by colons. Check if the directory that contains the C++ compiler binary (usually “/usr/bin”) is in the list. If it’s not, you can add it to the PATH environment variable by editing the “~/.bashrc” file and adding the following line at the end:

$ export PATH=$PATH:/usr/bin

Save the file and run the following command to apply the changes:

$ source ~/.bashrc

Filed Under: Linux, Ubuntu

Some more articles you might also be interested in …

  1. apparmor_status: command not found
  2. debchange Command Examples in Linux
  3. tlp-stat Command Examples in Linux
  4. CentOS / RHEL 6 : how to start the services interactively during boot (to disable/abort some services)
  5. “Logical volume vg/lv contains a filesystem in use” – while removing LVM filesystem
  6. resolvectl: command not found
  7. pivpn Command Examples in Linux
  8. “docker dead but subsys locked” – error while starting docker
  9. CentOS / RHEL : How to configure an DHCP server
  10. arping: Discover and probe hosts in a network using the ARP protocol (Command Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright