Important: Please read the Qt Code of Conduct -

Ubuntu: "QOpenGLShaderProgram shader program is not linked"

  • The app is written in PyQt and Qt both version 5.9. The app runs correctly on Mac OS X. (Edit: the app also runs correctly on Windows 7.) Moving the same source code to a linux system running 64-bit Ubuntu, the app displays a solid-black window and produces many multiple error sequences like:

    QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
    QOpenGLShaderProgram: could not create shader program
    QOpenGLShader: could not create shader
    shader compilation failed: ""

    There is no explicit use of OpenGL in the program, it uses just standard widgets, QMainWindow, QListView, and QWebEngineView.

    How do I tell it to quit trying to use OpenGL? Is there a style setting or something I can give to QApplication?

  • This problem is a specific Linux problem when the local graphics drivers are NVIDIA, but the linked is not the NVIDIA version.

    This is the Ubuntu bug that explains the issue, it is 4 years old!

    People on the PyQt mailing list provided this info, and suggested a simple work-around. Add the following code early in the setup of the app:

    if sys.platform.startswith( 'linux' ) :
        from OpenGL import GL

    The GL module will import the correct ( dll. Another suggested approach was to use ctypes,

    import ctypes

    I did not try this. A third approach would be to find the system and symlink it to however when I poked around the innards of Ubuntu 16 (64-bit) the number and links-between of the various libGL* files were more complicated than this simple idea would suggest so I did not try it.

Log in to reply