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

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

Problem Description

After installing Qt5.15.0, an error pops up when running a 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, the Qt platform plug-in "xcb" can be found but cannot be loaded. Although it is said that reinstalling may solve the problem, if this is possible, try to use it as the last option.

Positioning Problem

Modify the configuration file ~/.bashrc:

$ vim ~/.bashrc

Adding the following statement at the end will list detailed error messages when qtcreator is started.

export QT_DEBUG_PLUGINS=1

as follows:

Modify the configuration file

Save and exit editing to make the configuration file effective:

$ source ~/.bashrc

When starting qtcreator, the following detailed error message will pop up:

Detailed error information

At the bottom of the printed error message, the real cause of the error was found:

The real cause of the error

That is the problem of Qt dynamic link library. When loading libqxcb.so library, you also need to load libxcb-xinerama library.
Switch to the directory where the error libxcb.so is located:

#Replace with your own error directory$ cd /home/brainiac/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/

Run ldd libqxcb.so to view the associated content:

$ ldd libqxcb.so 

View Dependencies

It was found that the libxcb-xinerama.so.0 library does not exist.

Workaround

Install the libxcb-xinerama library:

#If there are other dependent libraries that have not been installed, install them as well.
$ 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 Solving

Run the qt program again and it will run normally.

Normal operation

postscript

I can happily code again.

Summarize

This is the end of this article about how to solve the problem of qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in Qt under Ubuntu 18.04. For more information about how to solve the problem of qt.qpa.plugin in Qt under Ubuntu 18.04, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed tutorial on installing qt5.12.8 and environment configuration on ubuntu18.04

<<:  Detailed tutorial for downloading and installing mysql8.0.21

>>:  Detailed explanation of the use of $emit in Vue.js

Recommend

How to deploy LNMP & phpMyAdmin in docker

Environmental preparation: Deploy lnmp on a host ...

How to configure whitelist access in mysql

Steps to configure whitelist access in mysql 1. L...

An article teaches you how to use js to achieve the barrage effect

Table of contents Create a new html file: Create ...

Unbind SSH key pairs from one or more Linux instances

DetachKeyPair Unbind SSH key pairs from one or mo...

Image scrolling effect made with CSS3

Achieve resultsImplementation Code html <base ...

Mysql method to copy a column of data in one table to a column in another table

mysql copy one table column to another table Some...

Solution to 1290 error when importing file data in mysql

Error scenario Use the mysql command in cmd to ad...

A graphic tutorial on how to install MySQL in Windows

Abstract: This article mainly explains how to ins...

How to reduce the memory and CPU usage of web pages

<br />Some web pages may not look large but ...

3 methods to restore table structure from frm file in mysql [recommended]

When mysql is running normally, it is not difficu...

Complete steps to implement location punch-in using MySQL spatial functions

Preface The project requirement is to determine w...

Token verification login in Vue project (front-end part)

This article example shares the specific code of ...

Tutorial on installing GreasyFork js script on mobile phone

Table of contents Preface 1. Iceraven Browser (Fi...

Practical notes on installing Jenkins with docker-compose

Create a Directory cd /usr/local/docker/ mkdir je...

Detailed Analysis of or, in, union and Index Optimization in MySQL

This article originated from the homework assignm...