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

could not find or load the Qt platform plugun "xcb"



  • Hi all,
    I try to run my executable file which is compiled by Qt. It shows a error message as below

    root@tegra-ubuntu:/home/ubuntu# ./SMPCodeReader1_ARM_exec
    Fatal: This application failed to start because it could not find or load the Qt platform plugin "xcb"
    in "".

    Reinstalling the application may fix this problem. (:0)
    Aborted
    root@tegra-ubuntu:/home/ubuntu#

    May I learn why this problem happened ? Thanks a lot.

    Note The packages are listed as below has installed on my TK1 platform.
    libx11-xcb-dev:armhf install
    libx11-xcb1:armhf install
    libx11-xcb1-dbg:armhf install
    libxcb-dri2-0:armhf install
    libxcb-dri2-0-dev:armhf install
    libxcb-dri3-0:armhf install
    libxcb-dri3-dev:armhf install
    libxcb-glx0:armhf install
    libxcb-glx0-dev:armhf install
    libxcb-icccm4:armhf install
    libxcb-image0:armhf install
    libxcb-keysyms1:armhf install
    libxcb-present-dev:armhf install
    libxcb-present0:armhf install
    libxcb-randr0:armhf install
    libxcb-randr0-dev:armhf install
    libxcb-render-util0:armhf install
    libxcb-render0:armhf install
    libxcb-render0-dev:armhf install
    libxcb-shape0:armhf install
    libxcb-shape0-dev:armhf install
    libxcb-shm0:armhf install
    libxcb-sync-dev:armhf install
    libxcb-sync1:armhf install
    libxcb-util0:armhf install
    libxcb-xfixes0:armhf install
    libxcb-xfixes0-dev:armhf install
    libxcb-xinerama0:armhf install
    libxcb-xinerama0-dev:armhf install
    libxcb-xkb1:armhf install
    libxcb1:armhf install
    libxcb1-dev:armhf install


  • Moderators

    @b108463 Your application can't find the xcb plugin for qt. It should be in /your/qt/path/plugins/platforms/libqxcb.so or something like that. You can install it for your application by using the dir structure:

    myapp
    plugins/
       platforms/
          libqxcb.so
    

    Or you can use a qt.conf file to point your plugins dir to your qt installation.

    Keep in mind this qt install has to match the architecture you are running, in this case I noticed you are using an ARM platform. So make sure your Qt is built for ARM.



  • @ambershark Thanks, but I don't understand it clearly.

    1. I found my libqxcb.so in /usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms/libqxcb.so

    2.I found the qt.conf in several paths
    /usr/share/qtchooser/qt5-arm-linux-gnueabihf.conf
    /usr/share/qtchooser/qt4-arm-linux-gnueabihf.conf
    /usr/lib/arm-linux-gnueabihf/qtchooser/qt5.conf
    /usr/lib/arm-linux-gnueabihf/qtchooser/qt4.conf

    Should I add the path of libqxcb.so in theses qt.conf?


  • Moderators

    @b108463 No you need to set it in the same directory as your binary.. i.e.

    $ cd /your/path/to/your/app
    $ echo "[Paths]" > qt.conf
    $ echo "Plugins = /usr/lib/arm-linux-gnueabihf/qt5/plugins" >> qt.conf
    

    Note, that will require your plugins to always be at that directory. Which they probably won't. So the better option for distribution is to make a bundle that contains the libs and plugins you need.



  • @ambershark

    1. It seems to create a qt.conf in the same folder as myapp,right?
    2. For 3rd step, it only write the "/usr/lib/arm-linux-gnueabihf/qt5/plugins" to qt.conf , not "/usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms" ?

    Sorry,I am a new user, so please forgive me to ask some basic questions. Thanks a lot.



  • Add more informatio as below

    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# ls -al
    total 13448
    drwxr-xr-x 2 root root 4096 Dec 29 06:50 .
    drwxr-xr-x 24 ubuntu ubuntu 4096 Dec 29 06:49 ..
    -rw-r--r-- 1 root root 57 Dec 29 06:50 qt.conf
    -rwxrwxrwx 1 root root 4630503 Dec 28 11:14 SMPCodeReader1_ARM_exec
    -rwxrwxrwx 1 root root 4502863 Dec 28 11:14 SMPCodeReader_ARM_exec
    -rwxrwxrwx 1 root root 4618254 Dec 27 10:03 SMPCodeReader_exe
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# cat qt.conf
    [Paths]
    Plugins=/usr/lib/arm-linux-gnueabihf/qt5/plugins
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# ls -al /usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms/libqxcb.so -al
    -rw-r--r-- 1 root root 441360 Apr 1 2015 /usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms/libqxcb.so
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# ./SMPCodeReader_ARM_exec
    Fatal: This application failed to start because it could not find or load the Qt platform plugin "xcb"
    in "".

    Reinstalling the application may fix this problem. (:0)
    Aborted
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC#


  • Moderators

    @b108463 said in could not find or load the Qt platform plugun "xcb":

    Add more informatio as below

    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# ls -al
    total 13448
    drwxr-xr-x 2 root root 4096 Dec 29 06:50 .
    drwxr-xr-x 24 ubuntu ubuntu 4096 Dec 29 06:49 ..
    -rw-r--r-- 1 root root 57 Dec 29 06:50 qt.conf
    -rwxrwxrwx 1 root root 4630503 Dec 28 11:14 SMPCodeReader1_ARM_exec
    -rwxrwxrwx 1 root root 4502863 Dec 28 11:14 SMPCodeReader_ARM_exec
    -rwxrwxrwx 1 root root 4618254 Dec 27 10:03 SMPCodeReader_exe
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# cat qt.conf
    [Paths]
    Plugins=/usr/lib/arm-linux-gnueabihf/qt5/plugins
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# ls -al /usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms/libqxcb.so -al
    -rw-r--r-- 1 root root 441360 Apr 1 2015 /usr/lib/arm-linux-gnueabihf/qt5/plugins/platforms/libqxcb.so
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC# ./SMPCodeReader_ARM_exec
    Fatal: This application failed to start because it could not find or load the Qt platform plugin "xcb"
    in "".

    Reinstalling the application may fix this problem. (:0)
    Aborted
    root@tegra-ubuntu:/home/ubuntu/SMPEXEC#

    Weird it's not picking up your path from qt.conf. Try putting a space before and after the = sign as I showed in my echo command above.

    And to answer your other question you only want the path to plugins, it will looks for platforms/libxxx underneath that.

    Here's an example of a linux distribution for one of my applications:

    .
    ./resources
    ./resources/APP-64.png
    ./resources/APP-32.png
    ./resources/messages.xml
    ./bin
    ./bin/myapp
    ./bin/qt.conf
    ./myapp
    ./INSTALL
    ./README
    ./libs
    ./libs/libstdc++.so.6
    ./libs/libQt5Core.so.5
    ./libs/libQt5Xml.so.5
    ./libs/libQt5Widgets.so.5
    ./libs/libsharkcore.so
    ./libs/libQt5XcbQpa.so.5
    ./libs/libQt5DBus.so.5
    ./libs/libgcc_s.so.1
    ./libs/libsharkcore.so.1.7.3
    ./libs/libQt5Network.so.5
    ./libs/libquazip.so.1.0.0
    ./libs/libQt5XmlPatterns.so.5
    ./libs/plugins
    ./libs/plugins/platforms
    ./libs/plugins/platforms/libqxcb.so
    ./libs/libQt5Gui.so.5
    ./libs/libQt5SerialPort.so.5
    

    And in qt.conf:

    [Paths]
    Plugins = ../libs/plugins
    

    And finally a startup script myapp:

    #!/bin/sh
    
    dir="$(dirname `readlink -f $0`)"
    LD_LIBRARY_PATH="$dir/libs:$LD_LIBRARY_PATH"
    export LD_LIBRARY_PATH
    exec $dir/bin/myapp "$@"
    

    Hopefully that helps clear things up on how to distribute apps for linux with Qt.


Log in to reply