CMake could not find OpenGL in Ubuntu

EDIT Following the answer, we don't need to install freeglut (SDK for windows) but installing mesa is enough.

You can install mesa an implementation of OpenGL. See indications in the answer.

Therefore, if you have an error such that:

Could NOT find OpenGL

Then, you want to install libgl1-mesa-dev. With debian-based system:

sudo apt-get install libgl1-mesa-dev

For an error, such that:

Could NOT find OpenGL (missing: EGL)

Then, you want to install libegl1-mesa-dev. With debian-based system:

sudo apt-get install libegl1-mesa-dev


You don't need any version of GLUT to satisfy a dependency on OpenGL. What you need is OpenGL headers and libraries. In Ubuntu they are installed with the libgl1-mesa-dev package.

To get the EGL build dependencies, replace the gl1 part of package name with egl1.