'Qt 5.12: Failed to find "GL/gl.h" in "/usr/include/libdrm"

I have a freshly installed Ubuntu 18.04.3 system (NVIDIA) with only Qt SDK 5.12.5, build-essential, git, and CMake installed. I'm trying to build a Qt project by opening the main CMakeLists.txt in Qt Creator:

Check for working CXX compiler: /usr/bin/g++
Check for working CXX compiler: /usr/bin/g++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at /home/juzzlin/Qt/5.12.5/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):
  Failed to find "GL/gl.h" in "/usr/include/libdrm".
Call Stack (most recent call first):
  /home/juzzlin/Qt/5.12.5/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:174 (include)
  /home/juzzlin/Qt/5.12.5/gcc_64/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:89 (find_package)
  CMakeLists.txt:89 (find_package)

What should I still install?

Note: I haven't installed Qt from repositories at all. Only via the official online installer.



Solution 1:[1]

You need mesa packages.

  • mesa-common-dev
  • libglu1-mesa-dev

$ sudo apt install mesa-common-dev libglu1-mesa-dev
And Try.

Solution 2:[2]

If anybody using Fedora/RHEL finds this question, mesa packages are named differently here.

  • mesa-libGL
  • mesa-libGL-devel

$ sudo dnf install mesa-libGL mesa-libGL-devel

Source: https://access.redhat.com/solutions/56301

Solution 3:[3]

In OpenSuse Leap mesa packages are named differently too.

Use:

sudo zypper install Mesa-libGL-devel

to solve it.
I tried it with OpenSuse Leap 15.2 and 15.3.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 juzzlin
Solution 2 vadkou
Solution 3 Sven Wickenhagen