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

Problem loading xcb on server



  • I am using a Jenkins server for CI and experience crashes when creating a QApplication, the code works on my home desktop PC. I am also using the Conan package manager on both systems.
    I was able to run non-widget Qt classes on the server (like QStandardItemModel) but once I try to start a QApplication in order to unit test a QDialog subclass, I receive an error. I never set any of the dialogs to visible.

    OS: Ubuntu 20.10
    GCC: 10.2
    Qt: 5.15.2

    ldd output:

    	linux-vdso.so.1 (0x00007ffcf418e000)
    	libQt5Charts.so.5 => /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/lib/libQt5Charts.so.5 (0x00007f84065e1000)
    	libQt5Core.so.5 => /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/lib/libQt5Core.so.5 (0x00007f8405b79000)
    	libQt5Gui.so.5 => /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/lib/libQt5Gui.so.5 (0x00007f8405319000)
    	libQt5Network.so.5 => /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/lib/libQt5Network.so.5 (0x00007f8404e52000)
    	libQt5Widgets.so.5 => /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/lib/libQt5Widgets.so.5 (0x00007f84047ad000)
    	libgsl.so.25 => /var/lib/jenkins/.conan/data/gsl/2.6/CHM/stable/package/cbd720b264ea52f357274d1a50ee7acd1fada4ff/lib/libgsl.so.25 (0x00007f84044cd000)
    	libgslcblas.so.0 => /var/lib/jenkins/.conan/data/gsl/2.6/CHM/stable/package/cbd720b264ea52f357274d1a50ee7acd1fada4ff/lib/libgslcblas.so.0 (0x00007f840448a000)
    	libQuantLib.so => /var/lib/jenkins/.conan/data/quantlib/1.1.0/_/_/package/0e93ca2780d1203d982f1bb6743054cb047a8d74/lib/libQuantLib.so (0x00007f8402410000)
    	libsoci_core.so.4.0 => /var/lib/jenkins/.conan/data/soci/4.0.1/_/_/package/b81e9aafd61b90ff3ce1fe6ec6a3435c788ac5dc/lib/libsoci_core.so.4.0 (0x00007f84023bf000)
    	libsoci_sqlite3.so.4.0 => /var/lib/jenkins/.conan/data/soci/4.0.1/_/_/package/b81e9aafd61b90ff3ce1fe6ec6a3435c788ac5dc/lib/libsoci_sqlite3.so.4.0 (0x00007f84022c0000)
    	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f84020d1000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f84020af000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8401f60000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8401f45000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8401d5b000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f8406e5e000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8401d55000)
    	libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f8401ccb000)
    	libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f8401c13000)
    	libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f8401bdf000)
    	libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f8401aa1000)
    	libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f8401a77000)
    	libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f8401a6f000)
    	libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f8401a67000)
    	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f8401a4d000)
    
    

    Output with QT_DEBUG_PLUGINS=1

    QFactoryLoader::QFactoryLoader() checking directory path "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms/libqlinuxfb.so"
    Found metadata in lib /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms/libqlinuxfb.so, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "linuxfb"
            ]
        },
        "archreq": 0,
        "className": "QLinuxFbIntegrationPlugin",
        "debug": false,
        "version": 331520
    }
    
    
    Got keys from plugin meta data ("linuxfb")
    QFactoryLoader::QFactoryLoader() looking at "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms/libqminimal.so"
    Found metadata in lib /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/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 "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms/libqoffscreen.so"
    Found metadata in lib /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/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 "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms/libqvnc.so"
    Found metadata in lib /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/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 "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/plugins/platforms/libqxcb.so"
    Found metadata in lib /var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/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 "/var/lib/jenkins/workspace/radingUi_feature_hk-514-init-cts/build/bin/platforms" ...
    loaded library "/var/lib/jenkins/.conan/data/qt/5.15.2/bincrafters/stable/package/1cc11643e0f63fe5a4fd5243867db3c8e801dd4c/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: linuxfb, minimal, offscreen, vnc, xcb.
    
    

    The server is only being used for CI and has no display attached, I don't know if that can cause the problem.



  • You can run the GUI tests on the CI server using xvfb:

    export DISPLAY=:99.0
    sh -e /etc/init.d/xvfb start
    sleep 3 # give xvfb some time to start
    ctest #start your Qt tests
    


  • @PatrykH said in Problem loading xcb on server:

    qt.qpa.xcb: could not connect to display

    The server is only being used for CI and has no display attached, I don't know if that can cause the problem.

    The issue is not with the libraries/build. It is just what it says: it needs a display. That's all i know, from previous questions/answers on this issue.

    I was able to run non-widget Qt classes on the server (like QStandardItemModel) but once I try to start a QApplication in order to unit test a QDialog subclass, I receive an error. I never set any of the dialogs to visible.

    Not setting them to visible won't help. A UI application needs a UI/display on start-up.



  • @JonB Ok, this makes sense, I was already suspecting this. I guess in that case I will just disable the Gui tests on the server and only run them locally.
    Thank you.



  • You can run the GUI tests on the CI server using xvfb:

    export DISPLAY=:99.0
    sh -e /etc/init.d/xvfb start
    sleep 3 # give xvfb some time to start
    ctest #start your Qt tests
    


  • @VRonin This works. I have to tweak it a bit, but from now on it becomes more of a Jenkins question. Thanks a lot!


Log in to reply