Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

David Cortesi
Probably some stupid misconfiguration? But a program that works perfectly on Win7 and almost perfectly on MacOS, on Ubuntu the window is completely black and a series of many iterations of the following appear in stderr:

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

The program uses only standard widgets e.g. QMainWindow, QListView, QWebEngineView. No explicit refs to QOpenG* anything.

Suggestions welcome...

Dave Cortesi


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

Chris Pezley
On 07/15/2017 07:38 PM, David Cortesi wrote:
Probably some stupid misconfiguration? But a program that works perfectly on Win7 and almost perfectly on MacOS, on Ubuntu the window is completely black and a series of many iterations of the following appear in stderr:

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

The program uses only standard widgets e.g. QMainWindow, QListView, QWebEngineView. No explicit refs to QOpenG* anything.

Suggestions welcome...

Dave Cortesi



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Try commenting out parts of the application bit by bit until you can find out which component it is that is causing this. Once you have that it will be easier to help.

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

Jérôme Laheurte-2
In reply to this post by David Cortesi

> Le 15 juil. 2017 à 19:38, David Cortesi <[hidden email]> a écrit :
>
> Probably some stupid misconfiguration? But a program that works perfectly on Win7 and almost perfectly on MacOS, on Ubuntu the window is completely black and a series of many iterations of the following appear in stderr:
>
> > QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
> > QOpenGLShaderProgram: could not create shader program
> > QOpenGLShader: could not create shader
> > shader compilation failed: ""
>
> The program uses only standard widgets e.g. QMainWindow, QListView, QWebEngineView. No explicit refs to QOpenG* anything.
>
> Suggestions welcome…
Install python-opengl and add something along the line of

if platform.system() == « Linux »:
    from OpenGL import GL

See https://github.com/spyder-ide/spyder/issues/3226

Best regards
Jérôme Laheurte


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

Jérôme Laheurte-2

> Le 17 juil. 2017 à 10:04, Jérôme Laheurte <[hidden email]> a écrit :

> Install python-opengl and add something along the line of
>
> if platform.system() == « Linux »:
>    from OpenGL import GL
>
> See https://github.com/spyder-ide/spyder/issues/3226

BTW with some versions of the nouveau driver, even after doing this, simply showing a QWebEngineView will crash your program very hard. The only thing that worked for me then was to use the proprietary NVidia driver…

Best regards
Jérôme Laheurte


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

Florian Bruhin
On Mon, Jul 17, 2017 at 10:06:56AM +0200, Jérôme Laheurte wrote:

>
> > Le 17 juil. 2017 à 10:04, Jérôme Laheurte <[hidden email]> a écrit :
>
> > Install python-opengl and add something along the line of
> >
> > if platform.system() == « Linux »:
> >    from OpenGL import GL
> >
> > See https://github.com/spyder-ide/spyder/issues/3226
>
> BTW with some versions of the nouveau driver, even after doing this,
> simply showing a QWebEngineView will crash your program very hard. The
> only thing that worked for me then was to use the proprietary NVidia
> driver…
FWIW, here's how you can detect that Nouveau is used:
https://github.com/qutebrowser/qutebrowser/blob/v0.11.0/qutebrowser/utils/version.py#L375-L422
(then check for opengl_vendor() == 'nouveau')

You can make it work by forcing software rendering via:
export QT_XCB_FORCE_SOFTWARE_OPENGL=1

Depending on your hardware, you either won't notice a difference, or it
will be too slow for every-day usage.

Florian

--
https://www.qutebrowser.org  | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

David Cortesi
Thanks to all who replied with useful references!

The key point seems to be (from https://github.com/spyder-ide/spyder/issues/3226):

> PyQt opens libGL.so, which on some systems is a link to the MESA GL library, not the NVIDIA GL library. The NVIDIA drivers should have changed that link to point to the NVIDIA library when they were installed, but didn't. As a result, PyQt is loading the wrong GL library.

See also the comment by Peter Würtz on the four year old (!!) Ubuntu issue here,
https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826/comments/25

I will experiment with symlinking libGL.so to libGL.so.1 to see if that makes a difference in my particular system. I will also try the workaround of importing GL only under Linux. However I mean to bundle the app with PyInstaller, and it will see that import and include the dependency on every platform anyway -- unless I maintain a special Linux version with that import.

Thanks again,
Dave Cortesi

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

Florian Bruhin
On Mon, Jul 17, 2017 at 07:36:24AM -0700, David Cortesi wrote:

> Thanks to all who replied with useful references!
>
> The key point seems to be (from
> https://github.com/spyder-ide/spyder/issues/3226):
>
> > PyQt opens libGL.so, which on some systems is a link to the MESA GL
> library, not the NVIDIA GL library. The NVIDIA drivers *should* have
> changed that link to point to the NVIDIA library when they were installed,
> but didn't. As a result, PyQt is loading the wrong GL library.
>
> See also the comment by Peter Würtz on the four year old (!!) Ubuntu issue
> here,
> https://bugs.launchpad.net/ubuntu/+source/python-qt4/+bug/941826/comments/25
Hmm, wait - if PyOpenGL only is needed so the correct library is loaded,
couldn't we just do the same using ctypes? I unfortunately don't have a
machine to test this, but can you try if this helps?

    import ctypes
    ctypes.cdll.LoadLibrary("libGL.so.1")

or maybe this:

    ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)

> I will experiment with symlinking libGL.so to libGL.so.1 to see if that
> makes a difference in my particular system. I will also try the workaround
> of importing GL only under Linux. However I mean to bundle the app with
> PyInstaller, and it will see that import and include the dependency on
> every platform anyway -- unless I maintain a special Linux version with
> that import.

FWIW you can just ignore an ImportError, and change your .spec file to
add OpenGL to PyInstaller's excludes on non-Linux systems.

Florian

--
https://www.qutebrowser.org  | [hidden email] (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Ubuntu, PyQt/Qt 5.9, QOpenGLShaderProgram "is not linked"

David Cortesi
OK I tested with the simple fix,

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

and it worked. Also as Florian suggested, using --exclude-module=OpenGL when building with PyInstaller for other platforms takes care of that issue.

I poked around inside Ubuntu 16.04 (64-bit) looking for libGL.so and there is just a mess of them.

   /usr/lib/x86_64-linux-gnu/libGL.so -> mesa/libGL.so
  /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
  /usr/lib/x86_64-linux-gnu/mesa/libGL.so -> libGL.so.1.2.0
  /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.11.2.2.32651
  /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 -> /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.11.2.2.32651


Since the original Ubuntu bug report (linked earlier) said the problem was using the "mesa" libs, and since I don't see anything nvidia-related dlls -- and since the import work-around fixed it -- I didn't want to mess with that. Perhaps ctypes.cdll.LoadLibrary("libGL.so.1") would pick up the last one, libGL.so.1.11.2.2.32651, but I don't know.



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Loading...