11

I reinstalled my ubuntu 14.04 and Qt 5.4.1 and Qtcreator.

Qt 5.4.1 was built from source with "-opensource -nomake-test -nomake-example" configure options.

When I open an old project in QtCreator and build it everything's OK.

But when I run this project it shows:

This application failed to start because it could not find or load the Qt platform plugin "xcb".

Available platform plugins are: linuxfb, minimal, offscreen, xcb.

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

So I googled this problem and tried everything. I installed every packages (libxcb series) but nothing can help!

Somebody help me please...

I tried your methods.

When I run ldd command in platform directory, It shows: ldd libqxcb.so under platform$

You can see that nothing is missing. And actually I have made a softlink in the platform directory called libqxcb.so. There was no libqxcb.so in my platform directory before.

And when I run ldd command to my executable. it shows: executable shot

And you can see the error when I execute this file.

OrionNebular
  • 197
  • 1
  • 2
  • 12
  • Did you read official documentation about deployment? What requests did you use in google? – Dmitry Sazonov Apr 02 '15 at 06:51
  • 1
    I read [this page](http://doc.qt.io/qt-5/linux-requirements.html) and installed all the packages it mentioned but nothing happened. And I searched google using "This application failed to start because it could not find or load the Qt platform plugin 'xcb '" request. – OrionNebular Apr 02 '15 at 08:45
  • http://doc.qt.io/qt-5/linux-deployment.html#application-dependencies – Dmitry Sazonov Apr 02 '15 at 10:09
  • 1
    Thanks, I tried this page. It's the same solution as the answer below. I use the `ldd` command but nothing happened. – OrionNebular Apr 02 '15 at 11:24

12 Answers12

21

For a similar issue, in my case I solved with:

export QT_PLUGIN_PATH=<qt base path>/plugins
BillyJoe
  • 878
  • 7
  • 25
  • 1
    Can't believe I had to search for so long to find this solution. How did you figure it out? – Haffi112 Jan 16 '17 at 19:39
  • Actually read it in other similar questions in stackoverflow. – BillyJoe Jan 17 '17 at 08:02
  • 8
    You can also set `export QT_DEBUG_PLUGINS=1` to get some better detail on what's going on. – wardw Dec 23 '18 at 13:28
  • sorry to ask but where exacly are you adding that line? im compiling on my rpi3, do you addit to the cmake when you compile? or its in other place on the rpi3? – lightshadown Apr 10 '23 at 16:47
  • 1
    @lightshadown it is a system variable. I was setting it from linux shell. I don't know in rpi3, it depends on the operating system. – BillyJoe Apr 10 '23 at 18:39
11

Try to go to the platforms folder of the Qt installation your program is using and run ldd libqxcb.so in a command prompt. Then check in the output if there are any missing dependencies. If the libqxcb.so is missing one of its dependencies this produces the output you mentioned.

You can also use the ldd command on your executable to check if there are any dependencies that can not be found.

Here is an example of what missing dependencies look like in the ldd output:

Example of <code>ldd</code> output

PS: the accepted answer of this question might also help you (creating a qt.conf file).

Community
  • 1
  • 1
bweber
  • 3,772
  • 3
  • 32
  • 57
  • I go to the `platform` directory and run `ldd libqxcb.so` command. Every dependencies was found, nothing was missing. And I also run `ldd` my executable but there is not dependency on `libqxcb.so`. Very strange... – OrionNebular Apr 02 '15 at 11:23
  • This is because libxcb.so is linked dynamically on startup, and ldd can only detects statically linked libraries. If there is no libxcb.so in the platform directory, either it wasn't built or it wasn't installed, check carefully the configure logs to see what happened. the softlink is 100% wrong. – HappyCactus Apr 02 '15 at 14:37
4

I just stuck into a very similar issue for hours, also nothing is "not found" in ldd results on related executable, or libqxcb.so. finally I found it's the issue with the executable itself but not Qt. Tried QT_QPA_PLATFORM='' executable and it works :)

frantic1048
  • 481
  • 4
  • 9
  • Thx. I had this problem with phantom.js but they seem to ignore it: https://github.com/ariya/phantomjs/issues/14377 – JepZ Feb 06 '17 at 03:04
  • Worked for me too on debian stretch. Another report of this can be found here: https://forum.antergos.com/topic/5239/phantomjs-complains-about-missing-qt-platform-plugin-xcb/3 – Benjamin Peter Aug 03 '17 at 10:02
3

I got this exact error on linux xubuntu 18.04

qt.qpa.plugin: 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.

Aborted (core dumped)

First, defining this environment variable before starting qtcreator from the commandline causes more debug to be printed out:

export QT_DEBUG_PLUGINS=1

And then in the debug it said this when trying to start qtcreator from the commandline on xubuntu 18.04:

Cannot load library /home/myuser/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)

Note that it cannot find libxkbcommon-x11, so the fix was this:

sudo apt-get install libxkbcommon-x11-dev
export PATH=$PATH:~/Qt/Tools/QtCreator/bin

Now qtcreator starts.

jmarina
  • 333
  • 1
  • 2
  • 8
2

'This application failed to start because it could not find or load the Qt platform plugin "xcb".'

See the accompanying web page, scroll down to heading "Qt Plugins". See first paragraph.

libqxcb.so is required, even if you link the rest statically.

http://doc.qt.io/qt-5/linux-deployment.html#application-dependencies

Qt have probably written their source code software to work in the following way: Instead of allowing libqxcb.so to be loaded at startup automatically (using rpath's) they use a dlopen() function to load it, as part of their QPA function set, soon after main() begins.

So this completely disregards our attempt to include all the "xcb" functions statically.

If their dlopen() fails they just trot out their error message we all know and hate, and then call signal 6 to abort it (quite unnecessarily) instead of exiting normally.

Clive
  • 269
  • 1
  • 14
1

for anyone that hasn't found the solution yet and desperately looking for an answer, this is a copy of what @wardw commented on the currently top rated answer, which helped me resolve my underlying issue.

export QT_DEBUG_PLUGINS=1

put this either in your run configuration or on the console before running your project and it will print more information about what is wrong.

Alex
  • 619
  • 1
  • 8
  • 25
1

This might be obvious, but I got this error while running a GUI from a (displayless) SSH session [ Why? I was developing an embedded app on a much larger screen, right next to the tiny touch screen it is intended for ].

Anyhow, in bash the following command targeted the app to its own screen:

export DISPLAY=':0.0'

Hope this helps someone.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Dave
  • 2,653
  • 4
  • 20
  • 22
1

In my case, i used Ubuntu 20.04 and this error stopped me from starting QT creator. i used the following command in a terminal:

export QT_DEBUG_PLUGINS=1

Then i ran the QT Creator from terminal again:

./qtcreator

then i had more detail error log:

Cannot load library /home/linhdh/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory) QLibraryPrivate::loadPlugin failed on "/home/linhdh/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/linhdh/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)" qt.qpa.plugin: 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.

Aborted (core dumped)

so i ran the following command:

sudo apt-get install libxcb-xinerama0

after installing libxcb-xinerama0 i can run qtcreator normally. The error was fixed.

Linh Dao
  • 1,305
  • 1
  • 19
  • 31
1

Install qtcreator 4.15.1 on Debian 10 have similar issue.

download qtcreator opensource

Show what library cause that error.

export QT_DEBUG_PLUGINS=1

Run /opt/qtcreator-4.15.1/bin/qtcreator

Search for corrupted lib ldd /opt/qtcreator-4.15.1/lib/Qt/plugins/platforms/libqxcb.so Find what library not link correctly.

Fix

Download library dependency and install it will fix.

sudo apt install ./libxcbutil1_0.4.0-1+b1_amd64.deb


source of answer

EsmaeelE
  • 2,331
  • 6
  • 22
  • 31
0
export QT_PLUGIN_PATH=<your qt installation path>/plugins/platforms

Similar to what mbjoe says, it really works!

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
wuqh
  • 9
  • 1
0

I solved the issue with that command:

sudo ln -s /usr/lib/x86_64-linux-gnu/libxcb-util.so.0 /usr/lib/x86_64-linux-gnu/libxcb-util.so.1

My python: 3.7.5

Package: PyQt5

Os: Linux(Debian)

Dream59
  • 101
  • 6
-1

Execute the command :

sudo ./app-name -platform linuxfb

Nikola Lukic
  • 4,001
  • 6
  • 44
  • 75