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

Fresh build of Qt 5.15: Could not load Qt platform plugin "xcb" in "" even though it was found



  • Hello,

    I've just compiled Qt 5.15 (.2) by obtaining it from download.qt.io, and obtained QtCreator via APT for Ubuntu 20.04.5 LTS. However, after downloading my application, and compiling it, it fails to start and throws the following error:

    qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, webgl.
    
    Press <RETURN> to close this window...
    

    It seems that the plugins aren't being found at all. Realising that perhaps this problem was caused by QtCreator not knowing where the plugins are, I located my Qt installation and set up the environment variable to point to the plugins directory there:

    • export QT_PLUGIN_PATH=/lib/x86_64-linux-gnu/qt5/plugins/

    Unfortunately, running this a second time didn't fix my problem. I just was told this time that the plugin can't be loaded, even though it was found:

    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: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb, webgl.
    

    A cursory search reveals this isn't the first time anyone's run into this problem. Notably, I came across this thread from the forum. I therefore performed the following:

    1. Enabled debugging for the plugins with export QT_DEBUG_PLUGINS=1
    2. Ran the executable again

    The more verbose error is as follows:

    QFactoryLoader::QFactoryLoader() checking directory path "/home/foo/Projects/foo-frontend/build-frontend-Desktop-Debug/platforms" ...
    Cannot load library /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so: (/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: _ZTI20QEventDispatcherGlib, version Qt_5_PRIVATE_API)
    QLibraryPrivate::loadPlugin failed on "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so" : "Cannot load library /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so: (/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: _ZTI20QEventDispatcherGlib, version Qt_5_PRIVATE_API)"
    

    The thread I linked earlier mentions you can solve this by simply installing a few missing packages:

    sudo apt-get install libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev
    

    However, after obtaining them all, cleaning my build, and rebuilding, the same error persists (yes, even despite having libxcb-xinerama0-dev).

    At this point, I'm at a bit of a loss as to how to fix this problem. I don't quite know how to wrangle with the libraries very well. I can list them here. Because this is related to xcb, I've listed all the libraries I have present here, as an output of sudo ldconfig -p | grep "xcb":

    	libxcb.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb.so.1
    	libxcb.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb.so
    	libxcb-xv.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xv.so.0
    	libxcb-xtest.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xtest.so.0
    	libxcb-xtest.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xtest.so
    	libxcb-xkb.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xkb.so.1
    	libxcb-xkb.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xkb.so
    	libxcb-xinput.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xinput.so.0
    	libxcb-xinerama.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xinerama.so.0
    	libxcb-xinerama.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xinerama.so
    	libxcb-xfixes.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xfixes.so.0
    	libxcb-xfixes.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-xfixes.so
    	libxcb-util.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-util.so.1
    	libxcb-sync.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-sync.so.1
    	libxcb-sync.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-sync.so
    	libxcb-shm.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-shm.so.0
    	libxcb-shm.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-shm.so
    	libxcb-shape.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-shape.so.0
    	libxcb-shape.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-shape.so
    	libxcb-res.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-res.so.0
    	libxcb-render.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-render.so.0
    	libxcb-render.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-render.so
    	libxcb-render-util.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-render-util.so.0
    	libxcb-render-util.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-render-util.so
    	libxcb-randr.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-randr.so.0
    	libxcb-randr.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-randr.so
    	libxcb-present.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-present.so.0
    	libxcb-keysyms.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-keysyms.so.1
    	libxcb-keysyms.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-keysyms.so
    	libxcb-image.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-image.so.0
    	libxcb-image.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-image.so
    	libxcb-icccm.so.4 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-icccm.so.4
    	libxcb-icccm.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-icccm.so
    	libxcb-glx.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-glx.so.0
    	libxcb-glx.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-glx.so
    	libxcb-dri3.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-dri3.so.0
    	libxcb-dri2.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxcb-dri2.so.0
    	libX11-xcb.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libX11-xcb.so.1
    	libX11-xcb.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libX11-xcb.so
    

    Hopefully someone can give me some pointers as to solving this.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You seem to be mixing your self built Qt and your system Qt.

    Are you sure you are using the correct one ?
    Is your kit correctly configured ?



  • @SGaist Hello, thank you for getting back to me so quick! It really shouldn't be using the system-build Qt. When configuring Qt in QtCreator, it by default had nothing selected. I went to the directory where the make install script had been moving the binaries and pointed it to qmake in there. Does anything so far sound fishy to you?

    If I have indeed built and installed Qt 5.15 correctly, what should I be looking at when configuring my kit?

    Cheers - Micrium


  • Lifetime Qt Champion

    You modified the QT_PLUGIN_PATH variable which should not be needed. Ensure that it did not pollute the environnement when running your application.

    Also, did you create a new kit for your custom Qt build ?



  • @SGaist Hello, and thanks for the response. I wasn't able to work on this on Sunday so I'm sorry for responding late.

    Basically, I've got a "manual" kit selected, where I've simply chosen GCC as the compilers and the Qt version to be 5.15. I've attached screenshots of my kit setup:

    alt text

    alt text

    Unfortunately, running without setting the plugin path basically sort of "regresses" the build error so that it simply doesn't detect the plugins whatsoever (instead of saying it found it, but that an error occurred):

    qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, webgl.
    
    Press <RETURN> to close this window...
    

    To revisit a point made earlier, I can get it to find libqxcb if I set the environment variable QT_QPA_PLATFORM_PLUGIN_PATH to point to /lib/x86_64-linux-gnu/qt5/plugins/platforms (instead of the default location, /usr/local/Qt-5.15.2/plugins/platforms). You might also be wondering what happens when I call ldd on the library. I'll just attach that here in case:

    Command: ldd /lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
    Result:

    	libQt5XcbQpa.so.5 => /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 (0x00007f941c782000)
    	libQt5Gui.so.5 => /lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f941c197000)
    	libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f941bc4e000)
    	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f941ba6d000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f941b87b000)
    	libfontconfig.so.1 => /lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f941b834000)
    	libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f941b773000)
    	libQt5DBus.so.5 => /lib/x86_64-linux-gnu/libQt5DBus.so.5 (0x00007f941b6d7000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f941b6b4000)
    	libX11-xcb.so.1 => /lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f941b6af000)
    	libxcb-xinput.so.0 => /lib/x86_64-linux-gnu/libxcb-xinput.so.0 (0x00007f941b68b000)
    	libxcb-icccm.so.4 => /lib/x86_64-linux-gnu/libxcb-icccm.so.4 (0x00007f941b684000)
    	libxcb-image.so.0 => /lib/x86_64-linux-gnu/libxcb-image.so.0 (0x00007f941b47d000)
    	libxcb-shm.so.0 => /lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f941b478000)
    	libxcb-keysyms.so.1 => /lib/x86_64-linux-gnu/libxcb-keysyms.so.1 (0x00007f941b473000)
    	libxcb-randr.so.0 => /lib/x86_64-linux-gnu/libxcb-randr.so.0 (0x00007f941b460000)
    	libxcb-render-util.so.0 => /lib/x86_64-linux-gnu/libxcb-render-util.so.0 (0x00007f941b459000)
    	libxcb-render.so.0 => /lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f941b44a000)
    	libxcb-shape.so.0 => /lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007f941b443000)
    	libxcb-sync.so.1 => /lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007f941b439000)
    	libxcb-xfixes.so.0 => /lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007f941b42f000)
    	libxcb-xinerama.so.0 => /lib/x86_64-linux-gnu/libxcb-xinerama.so.0 (0x00007f941b42a000)
    	libxcb-xkb.so.1 => /lib/x86_64-linux-gnu/libxcb-xkb.so.1 (0x00007f941b40c000)
    	libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f941b3e2000)
    	libXrender.so.1 => /lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f941b1d6000)
    	libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f941b099000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f941af4a000)
    	libSM.so.6 => /lib/x86_64-linux-gnu/libSM.so.6 (0x00007f941af3f000)
    	libICE.so.6 => /lib/x86_64-linux-gnu/libICE.so.6 (0x00007f941af21000)
    	libxkbcommon-x11.so.0 => /lib/x86_64-linux-gnu/libxkbcommon-x11.so.0 (0x00007f941af16000)
    	libxkbcommon.so.0 => /lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007f941aed2000)
    	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f941ada9000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f941ad8e000)
    	libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f941ad06000)
    	libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f941acce000)
    	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f941acb0000)
    	libharfbuzz.so.0 => /lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f941abab000)
    	libicui18n.so.66 => /lib/x86_64-linux-gnu/libicui18n.so.66 (0x00007f941a8ac000)
    	libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f941a6c6000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f941a6c0000)
    	libpcre2-16.so.0 => /lib/x86_64-linux-gnu/libpcre2-16.so.0 (0x00007f941a63d000)
    	libdouble-conversion.so.3 => /lib/x86_64-linux-gnu/libdouble-conversion.so.3 (0x00007f941a625000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f941c930000)
    	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f941a5f7000)
    	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f941a5ee000)
    	libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f941a59d000)
    	libxcb-util.so.1 => /lib/x86_64-linux-gnu/libxcb-util.so.1 (0x00007f941a397000)
    	libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f941a38f000)
    	libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f941a387000)
    	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f941a36d000)
    	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f941a2fa000)
    	libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f941a242000)
    	libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f941a20c000)
    	libgraphite2.so.3 => /lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f941a1df000)
    	libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f941871e000)
    	libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f941866f000)
    	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9418664000)
    	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f9418639000)
    	liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f9418618000)
    	libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f94184fa000)
    	libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f94184d7000)
    
    ``

  • Lifetime Qt Champion

    It seems that your build is incomplete if you do not have the plugin built and installed.

    Are you sure you installed all required development libraries ?



  • @SGaist To be honest I didn't add many flags to my ./configure command prior to building Qt5.15. I just chose those to auto-accept the open-source license. But I'm not aware of any X-specific flags. FYI, I'm building on an x86-64 platform under Ubuntu 20. Do you think I misconfigured something?

    As for the development libraries, I think I've installed just about everything under the sun (e.g. all these: https://doc.qt.io/qt-5/linux-requirements.html) . So I'm not sure what's left to do.

    For what it's worth, I can run my application under another plugin platform (e.g. linuxfb), but I'd really like to be able to do it under X.


  • Lifetime Qt Champion

    Please show the configuration summary.

    Note that you should at least add --no-make tests and --no-make examples to reduce the building time.



  • @SGaist I fixed it by just nuking my installation and starting over. I paid more attention to the output from ./configure, and made sure that EGLFS is enabled, along with EGLFS X11 under the EGLFS Details section. I also checked to ensure that Desktop OpenGL is enabled, along with EGL.

    I think whatever was going wrong must have been related to the configuration. Can you comment on the effect of installing libraries after running the configuration vs before? I've seen forum threads where people claim to install something like xinerama and suddenly their problem is magically gone. Should one always re-run configure after installing a new package to see if it is detected, and then re-build and re-install?

    Really appreciate your persistence in helping me. 10/10 experience.


  • Lifetime Qt Champion

    When adding new dependencies you should restart from a clean state. Just a call to configure might not catch the changes you applied to your system.

    As for when, always add all the development dependencies before calling configure.


Log in to reply