Struggling to build Qt due to missing OpenGL libraries

I'm trying to build an executable Qt-based program for Linux, and link Qt statically in the binary. According to the Qt docs, to do this I'm going to need to build Qt from source, starting with the commands:

cd /path/to/Qt
./configure -static -prefix /path/to/Qt

when I try this, I get a long bunch of output ending with:

ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.
Check config.log for details.

This isn't the first time I had problems with OpenGL and Qt... when I built my program with dynamic linking (using binary Qt libs) I got a similar problem, which I solved by symlinking to libGL.so from /usr/lib.

The output from configure said to go and find the "mkspec" for my platform, so I looked at Qt/5.13.1/Src/qtbase/mkspecs/linux-g++-64 (I explicitly told it to use that platform with the -platform command). I rooted around and tried setting those envvars to various combinations of paths that seemed plausible, to no avail.

It also mentioned a config.log file. When I look in this file, I can see open GL mentioned only in this block:

loaded result for library config.qtbase_gui.libraries.opengl
Trying source 0 (type pkgConfig) of library opengl ...
+ /usr/bin/pkg-config --exists --silence-errors gl
pkg-config did not find package. => source produced no result.
Trying source 1 (type makeSpec) of library opengl ...
Include path /usr/include/libdrm is invalid.
header entry 'config.qtbase_gui.libraries.opengl.headers.0' passed condition.
GL/gl.h not found in [/usr/include/libdrm] and global paths. => source produced no result.
test config.qtbase_gui.libraries.opengl FAILED
loaded result for library config.qtbase_gui.libraries.opengl_es2
Trying source 0 (type pkgConfig) of library opengl_es2 ...
+ /usr/bin/pkg-config --exists --silence-errors glesv2
pkg-config did not find package. => source produced no result.
Trying source 1 (type makeSpec) of library opengl_es2 ...
None of [libGLESv2.so libGLESv2.a] found in [] and global paths. => source produced no result.
test config.qtbase_gui.libraries.opengl_es2 FAILED

Indeed pkg-config --print-errors --exists gl can't find anything. No idea where it's getting that /usr/include/libdrm path...

7 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like