I am running 64 bit Ubuntu 14.04.

The compile error I am getting is:

In file included from ../../../Qt/5.4/gcc_64/include/QtOpenGL/qgl.h:39:0,
                 from ../../../Qt/5.4/gcc_64/include/QtOpenGL/qglshaderprogram.h:37,
                 from ../../../Qt/5.4/gcc_64/include/QtOpenGL/QGLShaderProgram:1,
                 from glwidget.h:5,
                 from glwidget.cpp:1:
../../../Qt/5.4/gcc_64/include/QtGui/qopengl.h:122:21: fatal error: GL/gl.h: No such file or directory
 #  include <GL/gl.h>

Strangely enough, I seem to have libGL.so properly installed and symlinked to the OpenGL libraries installed by my Nvidia 343 display driver (which I presume also installs OpenGL drivers).

$ ls -l /usr/lib | grep -i libgl
lrwxrwxrwx  1 root root           17 Jan 15 12:47 libGLESv1_CM.so -> libGLESv1_CM.so.1
lrwxrwxrwx  1 root root           22 Jan 15 12:47 libGLESv1_CM.so.1 -> libGLESv1_CM.so.343.36
-rwxr-xr-x  1 root root        48248 Jan 15 12:47 libGLESv1_CM.so.343.36
lrwxrwxrwx  1 root root           14 Jan 15 12:47 libGLESv2.so -> libGLESv2.so.2
lrwxrwxrwx  1 root root           19 Jan 15 12:47 libGLESv2.so.2 -> libGLESv2.so.343.36
-rwxr-xr-x  1 root root        62352 Jan 15 12:47 libGLESv2.so.343.36
-rw-r--r--  1 root root          654 Jan 15 12:47 libGL.la
lrwxrwxrwx  1 root root           10 Jan 15 12:47 libGL.so -> libGL.so.1
lrwxrwxrwx  1 root root           15 Jan 15 12:47 libGL.so.1 -> libGL.so.343.36
-rwxr-xr-x  1 root root      1274520 Jan 15 12:47 libGL.so.343.36

I've seen some previous posts that suggest doing

sudo apt-get install libglu1-mesa-dev freeglut3-dev mesa-common-dev

but when I tried that, it downgraded my supported OpenGL version (as outputted by glxinfo) to v1.4. Also I'm not sure why that's supposed to help.

Here is my glxinfo output.

$ glxinfo | grep -i opengl
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 970/PCIe/SSE2
OpenGL core profile version string: 4.3.0 NVIDIA 343.36
OpenGL core profile shading language version string: 4.30 NVIDIA via Cg compiler
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.4.0 NVIDIA 343.36
OpenGL shading language version string: 4.40 NVIDIA via Cg compiler
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:


  • 1
    Libraries and header files are different things: does your system have the mesa-common-dev package installed? – steeldriver Jan 15 '15 at 22:07

Regarding to for Qt doc:

The Qt installers for Linux assume that a C++ compiler, debugger, make, and other development tools are provided by the host operating system. In addition, building graphical Qt applications requires OpenGL libraries and headers installed. Most Linux distributions do not install all of these by default, but setting up a development environment is still straightforward.

Use the following commands to install the basic requirements for building Qt applications:

sudo apt-get install build-essential libgl1-mesa-dev
  • why? What will this help with? – Tim Jul 2 '15 at 19:03
  • If you read the doc that I point it above, you will know the reason – Habibillah Jul 3 '15 at 1:33

Ah, as @steeldriver points out, headers and libraries are different things, and doing the following fixed the issue:

sudo apt-get install mesa-common-dev

This installs the required headers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.