轉載於:https://www.jb51.net/article/193024.htm
問題描述
安裝Qt5.15.0后,在運行測試用例時彈出錯誤:
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)
根據問題描述,雖然能夠找到但是不能加載Qt平台插件“xcb”,雖然接下來又說重新安裝可能能夠解決,這個可能的話,還是盡量作為最下的選擇吧。
定位問題
修改配置文件~/.bashrc:
1
|
$ vim ~/.bashrc
|
在最末尾添加如下語句,會在qtcreator啟動時,列出詳細的錯誤提示。
1
|
export
QT_DEBUG_PLUGINS=1
|
如下:
保存退出編輯,使配置文件生效:
1
|
$
source
~/.bashrc
|
啟動qtcreator會彈出如下詳細錯誤信息:
在打印的錯誤信息的最下面,找到了引發錯誤的真正原因:
也就是Qt動態鏈接庫的問題,當加載libqxcb.so庫的時候,還需要加載libxcb-xinerama庫。
切換到報錯libxcb.so所在目錄:
1
2
|
#替換為自己的報錯目錄
$
cd
/home/brainiac/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/
|
運行ldd libqxcb.so,查看關聯內容:
1
|
$ ldd libqxcb.so
|
發現不存在libxcb-xinerama.so.0庫。
解決方法
安裝libxcb-xinerama庫:
1
2
|
#如果還存在其他依賴庫沒有安裝,也一並安裝。
$
sudo
apt-get
install
libxcb-xinerama0
|
安裝完成后,再次查看關聯內容,發現已經修復問題:
1
|
$ ldd libqxcb.so
|
再次運行qt程序,就可以正常運行了。
后記
又可以愉快的coding了。
總結
到此這篇關於Ubuntu18.04下解決Qt出現qt.qpa.plugin:Could not load the Qt platform plugin “xcb“問題的文章就介紹到這了,更多相關Ubuntu18.04解決Qt出現qt.qpa.plugin內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!
Problem:
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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted (core dumped)
Solution:
sudo apt-get install libxcb-xinerama0
在使用visdom進行可視化的時候,遇到了如下錯誤:
-
Setting up a new session...
-
[Errno 111] Connection refused
-
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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
求助於搜索引擎,發現網上問這個問題的挺多的,真是八仙過海各顯神通。
首先使用了
export QT_DEBUG_PLUGINS=1
然后重新運行程序,看到是
-
Got keys from plugin meta data ("xcb")
-
QFactoryLoader::QFactoryLoader() looking at "/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0"
-
"Failed to extract plugin meta data from '/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0'"
-
not a plugin
-
QFactoryLoader::QFactoryLoader() looking at "/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0.0.0"
-
"Failed to extract plugin meta data from '/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0.0.0'"
-
not a plugin
-
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/bin/platforms" ...
-
Cannot load library /usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: 無法打開共享對象文件: 沒有那個文件或目錄)
-
QLibraryPrivate::loadPlugin failed on "/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so
-
.0: 無法打開共享對象文件: 沒有那個文件或目錄)"
-
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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
嘗試了各種方法,好幾種都不湊效,
最終解決方案
sudo apt-get install libxcb-xinerama0
注意最后有個數字0