Solve the problem of qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in Qt under Ubuntu18.04

Solve the problem of qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in Qt under Ubuntu18.04

Problem Description

After installing Qt5.15.0, an error pops up when running the test case:

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)

According to the problem description, although the Qt platform plug-in "xcb" can be found but cannot be loaded, although it is said that reinstallation may be able to solve it, if this is possible, try to make it the lowest choice.

positioning problem

Modify the configuration file ~/.bashrc:

$ vim ~/.bashrc

Add the following statement at the end, and a detailed error message will be listed when qtcreator starts.

export QT_DEBUG_PLUGINS=1

As follows:
Modify the configuration file
Save and exit editing to make the configuration file take effect:

$ source ~/.bashrc

Starting qtcreator will pop up the following detailed error message:
detailed error message
At the bottom of the printed error message, the real cause of the error is found:
The real cause of the error
that is, the problem of the Qt dynamic link library. When loading the libqxcb.so library, you also need to load libxcb-xinerama library.
Switch to the directory where the error libxcb.so is located:

#替换为自己的报错目录
$ cd /home/brainiac/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/

Run ldd libqxcb.so to view related content:

$ ldd libqxcb.so

View dependencies
Found that the libxcb-xinerama.so.0 library does not exist.

Solution

Install the libxcb-xinerama library:

#如果还存在其他依赖库没有安装,也一并安装。
$ sudo apt-get install libxcb-xinerama0

After the installation is complete, check the associated content again and find that the problem has been fixed:

$ ldd libqxcb.so

problem solved
Run the qt program again and it will work normally.
normal operation

postscript

You can code happily again.

Guess you like

Origin blog.csdn.net/LOVEmy134611/article/details/107212845