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

Detailed introduction to Mysql date query

Query the current date SELECT CURRENT_DATE(); SEL...

Bugs encountered when using mybatis-generator with mysql8.0.3 in IDEA

1. Add the plug-in and add the following configur...

A simple example of MySQL joint table query

MySql uses joined table queries, which may be dif...

MySQL learning database backup detailed explanation

Table of contents 1.DB,DBMS,SQL 2. Characteristic...

Example of how to implement underline effects using Css and JS

This article mainly describes two kinds of underl...

How to encapsulate the carousel component in Vue3

Purpose Encapsulate the carousel component and us...

...

JavaScript implementation of verification code case

This article shares the specific code for JavaScr...

Examples and comparison of 3 methods for deduplication of JS object arrays

Table of contents 1. Comparison of data before an...

How to allow remote access to open ports in Linux

1. Modify the firewall configuration file # vi /e...

Vue implements internationalization of web page language switching

1. Basic steps 1: Install yarn add vue-i18n Creat...

JavaScript Basics Variables

Table of contents 1. Variable Overview 1.1 Storag...

Implementation of navigation bar and drop-down menu in CSS

1. CSS Navigation Bar (1) Function of the navigat...