How to fix the error "cmake command not found"

Endrit Qerreti

Endrit Qerreti

cmake is a tool that you can use to build and compile c and c++ projects.

If you are getting the error "cmake command not found" on the terminal when trying to build a project with cmake, it simply means that cmake it's not installed on your system.

In this tutorial we are using Debian 12, however cmake can be easily installed on any Debian based linux distro.

In this tutorial, you will learn how to fix the error " cmake command not found" on Linux

Step 1 - Update your system

It is important to update your system before installing cmake

Run the command below to check for updates on your Debian machine and install updates if prompted

sudo apt update

Step 2 - Install cmake

cmake can be downloaded and installed on Debian 12 from the terminal directly as cmake is available on Debian repositories.

To install cmake, simply run the command below

sudo apt install cmake -y

Step 3 - Verify cmake installation

Now cmake should be installed on your system. To verify that cmake was successfully installed, you can run the --version command.

cmake --version

The version command will display the version of cmake, which means that the cmake was installed correctly.

However, to check if cmake command is able to build a project, then you can use the build command, navigate to the build directory of the project that you want to build, and run the command below

cd build && cmake ..

Conclusion

In this tutorial, we explained what the error "cmake command not found" means, why it happens and how to fix it.

Even though we used Debian 12 for this tutorial, you can follow the same steps to fix "cmake command not found" error on other Linux distros.

I hope this tutorial helped you to fix this error.