Cmake does not find Opengl during build

Hello, I am trying to build a software using Cmake.

I do so by typing cmake .

The result it is:

Normal Build
Using X11 for Vulkan
CMake Error at /home/leopoldo/Arquivos-de-Programas-Linux/Cmake-3.19.2-Linux-x86_64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY)
Call Stack (most recent call first):
/home/leopoldo/Arquivos-de-Programas-Linux/Cmake-3.19.2-Linux-x86_64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/home/leopoldo/Arquivos-de-Programas-Linux/Cmake-3.19.2-Linux-x86_64/share/cmake-3.19/Modules/FindOpenGL.cmake:421 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)

My system supplies the Opengl librarie on: /usr/lib/mesa, where and symbolic links to it, and exists

There was not the header files rela to OpenGL, however I downloaded them and created symbolic links to it on /usr/local/include/GL.

There, there is:

glext.h gl.h glu.h glu_mangle.h glxext.h glx.h KHR

where KHR is a dir with khrplatform.h inside of it.

So what Cmake looks for that I am not supplying?

It looks like the headers aren’t the problem, but the libraries. The --debug-find flag should help give more information about the search process.

Cc: @chuckatkins

Ok I just used it and the result was wierd. While the GL library was not in any searched path the libGLU was and yet cmakes says it canno find it:

find_library called with the following settings:

Documentation: Path to a library.
  Only Search Frameworks: 0
  Search Frameworks Last: 0
  Search Frameworks First: 0
  Only Search AppBundle: 0
  Search AppBundle Last: 0
  Search AppBundle First: 0

find_library considered the following locations:


/usr/lib it is where libGLU is at and yet it says cannot find it?
Anyway I created a symbolic link from /usr/lib/mesa to /usr/local/lib and it stopped to complain, even though ligGLU was not find, as libGLX and another OpenGL library that has an ‘E’ in the name. And even more strange, is that then I deleted the symbolic link and it does not complain more about libGL! (I wanted to use CMAKE_PREFIX_PATH instead.

Hmm. I am not sure what would be the cause here. @robert.maynard Thoughts?