“Failed to load platform plugin ”xcb“ ” while launching qt5 app on linux without qt installed

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.


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

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.