29

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.

15 Answers 15

23

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.

| improve this answer | |
  • 2
    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 '19 at 13:27
  • What do you do if the trace doesn't give you any error and then simply says seg fault? :/ – Firebug Feb 9 at 21:17
14

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
| improve this answer | |
  • Wow, what a mess of a hunt this was trying various reinstalls. So grateful for this. – Hendy Sep 20 '18 at 1:01
  • This helped!!! thanks – trsvchn Nov 26 '19 at 13:55
  • No missing files, none. – John Smith May 26 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 at 4:17
11

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.

| improve this answer | |
  • 1
    This solved the problem for me. – Pratik Singhal Sep 2 '17 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 '18 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 '19 at 6:26
8

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

| improve this answer | |
3

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

| improve this answer | |
3

Running this solved it to me:

sudo apt-get --reinstall install libqt5dbus5 \
libqt5widgets5 libqt5network5 libqt5gui5 libqt5core5a \
libdouble-conversion1 libxcb-xinerama0
| improve this answer | |
2

In my ubuntu type:

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

Can work

| improve this answer | |
  • 1
    This is not a good answer as it stands. Please edit to explain what exactly that command does. – You'reAGitForNotUsingGit May 14 '16 at 0:23
  • Did not worked for me – Ratbert Apr 1 '19 at 9:03
2

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.

| improve this answer | |
2

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
| improve this answer | |
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.

| improve this answer | |
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

| improve this answer | |
0

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.

| improve this answer | |
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

| improve this answer | |
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!

| improve this answer | |
-1

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

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.