Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qt.qpa.xcb: could not connect to display AND Failed to create OpenGL context for format QSurfaceFormat



  • I get the following error upon deploying on target (debug mode):

    17:12:34: Starting /root/p3 ...
    QML debugging is enabled. Only use this in a safe environment.
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqminimal.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqminimal.so, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "minimal"
    ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331520
    }

    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqoffscreen.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqoffscreen.so, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "offscreen"
    ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331520
    }

    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqvnc.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqvnc.so, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "vnc"
    ]
    },
    "archreq": 0,
    "className": "QVncIntegrationPlugin",
    "debug": false,
    "version": 331520
    }

    Got keys from plugin meta data ("vnc")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqxcb.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqxcb.so, metadata=
    {
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
    "Keys": [
    "xcb"
    ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331520
    }

    Got keys from plugin meta data ("xcb")
    QFactoryLoader::QFactoryLoader() checking directory path "/root/platforms" ...
    loaded library "/usr/lib/plugins/platforms/libqxcb.so"
    qt.qpa.xcb: could not connect to display
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

    Available platform plugins are: minimal, offscreen, vnc, xcb.

    17:12:34: Remote process crashed.

    Also, if I use "Release" mode I get infinite warnings stating qml_qmcache not found

    So then I've tried using -platform offscreen and then I got the following error:

    loaded library "/usr/lib/.../libwindowplugin.so"
    QFactoryLoader::FactoryLoader() checking dirrectory path "..."
    QFactoryLoader::FactoryLoader() checking dirrectory path "..."
    QFactoryLoader::FactoryLoader() checking dirrectory path "..."
    QFactoryLoader::FactoryLoader() checking dirrectory path "..."
    Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options ...)
    Aborted.

    The target is an rpi3.

    What seems to be the problem here?


  • Lifetime Qt Champion

    Hi
    Is that running Rasberry Debian with an X11 server ?

    Could be that XCB is missing
    libxcb-xinerama0-dev
    libxcb-xinerama0

    which has been the issue on some posts here regarding upgrading the os/Qt.

    Not sure it applies to the arm version but its worth a shot.



  • @mrjj Hey, I've already tried installing libxcb-xinerema0 ( -dev didn't work) but this was the error still.


  • Lifetime Qt Champion

    @johnyboy
    Hi
    Could you try ldd on the plugin to see if something still missing ?

    (I assume its yes to X11 server etc)



  • @mrjj I will try and come back to you, I don't use X11 I use gles2 btw may that pose a problem?


  • Lifetime Qt Champion

    Hi
    well if you dont have any windows manager running then it will be an issue for xcb.



  • I second everything @mrjj has said so far.

    It seems that the absence of a window manager might be the key issue here.

    However, in case other people end up on this page due to a matching error phrase, I will share a workaround that I encountered for OpenGL/QSurfaceFormat errors in the past.

    A couple years ago I was working on a Qt/QML project and I was using Xephyr during testing to create the X display. A subset of team members experienced an OpenGL-related issue. It seemed to depend on each person's graphics hardware. We ended up with a technical memo that said something like "when launching the app for testing, if you see any error about OpenGL, GLX, EGL, QSurface, or similar, the workaround is to install VirtualGL from virtualgl.org and insert vglrun into the command, like so:"

        DISPLAY=:12 vglrun -- $PROJECT_HOME/build/projectname/gui/test_app &
    


  • if you dont have any windows manager running then it will be an issue for xcb.

    Yes, it looks like @mrjj is right here.

    However, you could still run the Qt app in the RPi device and make it display on another machine if you connect via SSH with X Forwarding enabled.

    $ ssh -X user@RPi /path/to/your/Qt/app -platform xcb
    

Log in to reply