# Cmake does not find Opengl during build

**URL:** https://discourse.cmake.org/t/cmake-does-not-find-opengl-during-build/2517
**Category:** Usage
**Created:** [January 12, 2021, 2:59pm UTC](https://discourse.cmake.org/t/cmake-does-not-find-opengl-during-build/2517 "2021-01-12T14:59:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![colt](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@colt](https://discourse.cmake.org/u/colt)
#### Post date: [January 12, 2021, 2:59pm UTC](https://discourse.cmake.org/t/cmake-does-not-find-opengl-during-build/2517/1 "2021-01-12T14:59:23Z")

</div>

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 libGL.so.1.2 and symbolic links to it, libGL.so.1 and libGL.so 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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 12, 2021, 3:02pm UTC](https://discourse.cmake.org/t/cmake-does-not-find-opengl-during-build/2517/2 "2021-01-12T15:02:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![colt](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@colt](https://discourse.cmake.org/u/colt)
#### Post date: [January 15, 2021, 1:42am UTC](https://discourse.cmake.org/t/cmake-does-not-find-opengl-during-build/2517/3 "2021-01-15T01:42:10Z")

</div>

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:

```
VAR: OPENGL_glu_LIBRARY
NAMES: "GLU"
       "MesaGLU"
Documentation: Path to a library.
Framework
  Only Search Frameworks: 0
  Search Frameworks Last: 0
  Search Frameworks First: 0
AppBundle
  Only Search AppBundle: 0
  Search AppBundle Last: 0
  Search AppBundle First: 0
CMAKE_FIND_USE_CMAKE_PATH: 1
CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1

```

find\_library considered the following locations:

```
/usr/local/sbin/(lib)GLU(\.so|\.a)
/usr/local/bin/(lib)GLU(\.so|\.a)
/usr/sbin/(lib)GLU(\.so|\.a)
/usr/bin/(lib)GLU(\.so|\.a)
/sbin/(lib)GLU(\.so|\.a)
/bin/(lib)GLU(\.so|\.a)
/usr/games/(lib)GLU(\.so|\.a)
/usr/local/lib/(lib)GLU(\.so|\.a)
/usr/local/(lib)GLU(\.so|\.a)
/usr/lib/(lib)GLU(\.so|\.a)
......
...... 

```

/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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 19, 2021, 7:30pm UTC](https://discourse.cmake.org/t/cmake-does-not-find-opengl-during-build/2517/4 "2021-01-19T19:30:43Z")

</div>

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