83

I wrote application for linux which uses Qt5.

But when I am trying to launch it on the linux without Qt SDK installed, the output in console is:

Failed to load platform plugin "xcb". Available platforms are:

How can I fix this? Maybe I need to copy some plugin file? When I use Ubuntu with Qt5 installed, but I rename Qt directory, the same problem occurs. So, it uses some file from qt directory...

I have found file libqxcb.so in the Qt SDK directory, but placing it in /usr/lib does not help.

1
  • Very old question and I do not have the rep to answer, but for anyone browsing. I had this issue and tried many approaches... eventually my work around was to deploy via my existing Anaconda-navigator installation which worked seamlessly.
    – RichardBJ
    Dec 10, 2020 at 13:18

17 Answers 17

75

I had this error message when trying to run "Stellarium".

With strace I found that the missing file was libxcb-xinerama.so.0. I had to reinstall libxcb-xinerama0 to make it work:

sudo apt-get install --reinstall libxcb-xinerama0
8
  • 3
    Wow, what a mess of a hunt this was trying various reinstalls. So grateful for this.
    – Hendy
    Sep 20, 2018 at 1:01
  • No missing files, none.
    – John Smith
    May 26, 2020 at 7:49
  • It fixed my problem with Evan"s Debugger too, after 20 minutes searching this is a day saver. Many thanks.
    – Agguro
    Aug 3, 2020 at 4:17
  • Thanks man. I'm getting this error and your solution works.
    – user218477
    Aug 9, 2020 at 11:39
  • This did the trick for me as well on a fresh Ubuntu installation, thank you! Except I did not need to --reinstall, it was simply not installed. Nov 18, 2020 at 8:14
69

To any future readers who come across this - before you start (dangerously) messing around with symlinks to shared libraries, I strongly suggest that you run

export QT_DEBUG_PLUGINS=1

and then run your failing executable again in the Terminal. Read the actual error message thrown by QT, since none of the above solutions addressed the cause of this error in my case.

My output after turning on QT_DEBUG_PLUGINS was:

QFactoryLoader::QFactoryLoader() checking directory path "/opt/PostgreSQL/9.6/pgAdmin 4/bin/platforms" ...
loaded library "/opt/PostgreSQL/9.6/pgAdmin 4/plugins/platforms/libqxcb.so"
QLibraryPrivate::loadPlugin failed on "/opt/PostgreSQL/9.6/pgAdmin 4/plugins/platforms/libqxcb.so" : "Cannot load library /opt/PostgreSQL/9.6/pgAdmin 4/plugins/platforms/libqxcb.so: (/opt/PostgreSQL/9.6/lib/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16))"
This application failed to start because it could not find or load the Qt platform plugin "xcb".

Available platform plugins are: xcb.

Reinstalling the application may fix this problem.
Aborted (core dumped)

so I then googled the version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16)) error and found the solution to that, which solved the problem.

5
  • 4
    Not sure who down voted you. This gave me the traces needed to find the actual error relevant to my specific situation (in my case libc++.so was missing and had to be installed from libc++-dev". Thank you for posting this.
    – HBSKan
    Apr 10, 2019 at 13:27
  • 2
    What do you do if the trace doesn't give you any error and then simply says seg fault? :/
    – Firebug
    Feb 9, 2020 at 21:17
  • 4
    Another env variable that might help is QT_PLUGIN_PATH, e.g. export QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins
    – jlb
    Apr 9, 2021 at 16:24
  • I was able to successfully run Viber after I followed this steps and install the missing lib files.
    – r2b2
    May 12, 2021 at 8:18
  • [centos7 here] i ran ldd on the .so file libqxcb.so and it revealed that there was about 5 missing .so files that were not found. so then i ran yum whatprovides *lib*/${filename} for each of the missing .so files and installed the required rpm file for each missing .so file that was not found. Feb 15, 2022 at 20:20
25

Try to install libqt5x11extras5 package with command:
sudo apt-get install libqt5x11extras5

The name may be different. You can figure it out by searching:
sudo apt-cache search qt5 | grep 'X11 extras'

and u get the name of the package as result:

libqt5x11extras5 - Qt 5 X11 extras

3
  • This is what I needed to get Zoom to work on Ubuntu 20.04.
    – may
    Dec 7, 2020 at 20:10
  • 1
    This is what I needed to get Qt5 working on WSL!
    – Tropilio
    Jan 11, 2023 at 17:29
  • Worked for installing Dropbox on Debian 10. Jun 18, 2023 at 23:18
16

The correct solution is running the following comand onto a terminal:

sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/

It creates the symbolic link it's missed.

4
  • 2
    This solved the problem for me. Sep 2, 2017 at 14:15
  • 3
    Why do you link the files in plugins/platforms to /usr/bin? The platforms directory contains shared libraries, /usr/bin is used for binary files. Shouldn't the contents of platforms go into /usr/lib?
    – Nathan F.
    Apr 20, 2018 at 14:52
  • @NathanF. at least for my installation the Qt loader searches for platforms at /usr/bin/platforms (I don't know why). So this answer also worked for me: stackoverflow.com/a/25437758/2249798
    – m13r
    Sep 23, 2019 at 6:26
  • shouldn't the last part be the name of a symbolic link? (it just says /usr/bin/) Feb 1 at 11:02
8

Running this solved it to me:

sudo apt-get --reinstall install libqt5dbus5 \
libqt5widgets5 libqt5network5 libqt5gui5 libqt5core5a \
libdouble-conversion1 libxcb-xinerama0
1
  • Still works in 2023 for Ubuntu 20.04
    – Wajih
    Mar 27, 2023 at 7:28
5

For those who are still stuck after trying every other option out there in the internet, you can look into exact path from which this notorious libqxcb.so is being searched in, for opening/loading by the Qt App(VirtualBox-5.2.8 is the Qt app in my case), using the strace tool. In my case, since I was building VirtualBox-5.2.8 from its source, it was searching for libqxcb.so in the below location :
"...VirtualBox-5.2.8/out/linux.amd64/release/bin/platforms/" and not in the default library paths, Qt installation path, etc. So, none of the ldd checks, and other solutions worked. And also setting QT_DEBUG_PLUGINS=1 didn't produce any extra logs either.

Running strace on the the VirtualBox binary I built using Clang/LLVM on Ubuntu 17.10 x86_64:

...VirtualBox-5.2.8$ strace ./out/linux.amd64/release/bin/VirtualBox

.
.
.
access(".../VirtualBox-5.2.8/out/linux.amd64/release/bin/platforms/.", F_OK) = -1 ENOENT (No such file or directory)
write(2, "Qt FATAL: ", 10Qt FATAL: )              = 10
write(2, "This application failed to start"..., 154This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.) = 154
.
.
.

That was my hitting-the-nail-on-its-head moment, and I created the symlink from the installed Qt5.10.1's platforms directory mentioned below : "...Qt5.10.1/Tools/QtCreator/lib/Qt/plugins/platforms/" onto the searched path which is "...VirtualBox-5.2.8/out/linux.amd64/release/bin/". Thus, VirtualBox-5.2.8 built from source on Linux(Ubuntu 17.10 x86_64) using Clang/LLVM, finally launched successfully!

In fact, another interesting thing here is that, I have built VirtualBox-5.2.8 entirely using Clang/Clang++/LLVM on Ubuntu 17.10 x86_64 after substantial effort - for FreeBSD, there's already a port for building VirtualBox using clang but for Linux, it's heavily dependent on GCC as I saw and hence it took a lot of effort to get to this point to be able successfully build VirtualBox-5.2.8 from its source using Clang/Clang++/LLVM on Ubuntu 17.10 x86_64 for target Linux/AMD64(Ubuntu 17.10 x86_64) and successfully launch it after resolving other issues along with this notorious libqxcb.so one.

Cheers.

4

Run ldd on your application executable to see how it resolves library dependencies.

Also this is a must read to understand what essential libraries are needed in simple case of gui application:

http://qt-project.org/doc/qt-5/linux-deployment.html

4

In my ubuntu type:

sudo ln -sf /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/ /usr/bin/platforms

Can work

2
  • 2
    This is not a good answer as it stands. Please edit to explain what exactly that command does. May 14, 2016 at 0:23
  • Did not worked for me
    – Ratbert
    Apr 1, 2019 at 9:03
3

This is how solve few issues when I am running emulator on Ubuntu 18.04.

$ vim ~/.bashrc

Add the following lines at the end of file. I install my Android SDK at /opt/Android/Sdk

export ANDROID_HOME=/opt/Android/Sdk
export ANDROID_SDK_ROOT=/opt/Android/Sdk
export ANDROID_AVD_HOME=/home/<your name>/.android/avd
export LD_LIBRARY_PATH="/opt/Android/Sdk/emulator/lib64:$LD_LIBRARY_PATH"
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins
1

Platform: Kubuntu 18.

In my case, I did strace -f -s 1000 zoom -o zoom.trace, then studied zoom.trace. There was a lot of output. I searched for SIGABRT to narrow things down. The problem was that when Zoom launched /usr/bin/kde-open5, that process was hitting an internal assert right after trying to stat /usr/bin/platforms. On a whim, I did this:

 sudo ln -s /opt/zoom/platforms /usr/bin/platforms

and that got Zoom working. I realize that there are other issues with the KDE/QT installation that perhaps need to be fixed, but this was good enough for me to solve the problem for now.

0

It seems there can be various different things missing behind this. In my case (Debian 9.7), QT_DEBUG_PLUGINS=1 did help to trace back the missing libraries, and

$ sudo apt-get install libxcb-render-util0 libxcb-image0 libxcb-keysyms1 libxcb-icccm4

solved the problem.

0

Create file qt.conf in your project and add:

[Paths]
Plugins = /path/to/our/qt instalation/plugins

https://doc.qt.io/qt-5/qt-conf.html

0

The other answers here are very useful, but there is another potential cause for this behavior I've experienced which requires a completely different solution.

I was running Ubuntu 18.04 on VirtualBox 6.1.4, and after installing some proprietary applications my work uses, all Qt5 applications would fail to start. Like everyone else here, they printed an error message regarding their inability to load "xcb". After poking around for a while, I realized that "/usr/lib" was no longer being indexed by ldconfig. I'm surprised that this broke as few applications as it did, probably due to the fact that "/usr/lib/x86_64-linux-gnu" was still being indexed.

If you have the same problem, the fix is easy. Just add "/usr/lib/" to LD_LIBRARY_PATH using any one of these methods

0

I faced the similar problem but with another application vkreplay as part of Vulkan.

You can try using strace to help see what's going on behind the scene (trace system calls and signals) in its attempt of loading shared library like following.

strace vkreplay -o vkcube_trace.vktrace -l 2

or

strace <your-command> <your-command-parameters>

for my case, I saw the following message dumped out

...
stat("/usr/lib/x86_64", 0x7ffc5f1c2aa0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/x86_64/libxcb-ewmh.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7ffc5f1c2aa0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/libxcb-ewmh.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
munmap(0x7fac93723000, 114202)          = 0
munmap(0x7fac92f9d000, 2109784)         = 0
munmap(0x7fac92f8b000, 69736)           = 0
...

Shared library in question is libxcb-ewmh.so.2 which is failed to load. Then I do apt search libxcb-ewmh, on my distro Ubuntu 19.10, I've found it's libxcb-ewmh2. Then you install it with sudo apt install libxcb-ewmh2.

At last, problem solves!

0

read closely, in case: QLibraryPrivate::loadPlugin failed on "/foo../venv/lib/python3.8/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /foo../venv/lib/python3.8/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so: (libxcb-util.so.1: cannot open shared object file: No such file or directory)"

so it misses: https://packages.debian.org/sid/libxcb-util1

for debian not sid/bullseye backport it to your version eg stretch/buster, see https://backports.debian.org/Instructions/

0

I had this error when starting Dropbox, and fixed it by deleting ~/.dropbox-dist, restarting Dropbox (command line: dropbox start -i) and allowing it to (re)install its proprietary daemon.

-1

Copy plugins/platforms/libqxcb.so from your qt install to platforms/libqxcb.so in your application directory.

1
  • what application directory? /usr/bin? Feb 1 at 11:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .