Ubuntu18.04下解決Qt出現qt.qpa.plugin:Could not load the Qt platform plugin “xcb“問題


轉載於:https://www.jb51.net/article/193024.htm

 更新時間:2020年08月11日 09:39:48   作者:盼小輝丶  
 
這篇文章主要介紹了Ubuntu18.04下解決Qt出現qt.qpa.plugin:Could not load the Qt platform plugin “xcb“問題,本文給大家分享解決方案,需要的朋友可以參考下
 

問題描述

安裝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進行可視化的時候,遇到了如下錯誤:

  1. Setting up a new session...

  2. [Errno 111] Connection refused

  3. qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

  4. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

  5.  
  6. 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

然后重新運行程序,看到是

  1. Got keys from plugin meta data ("xcb")

  2. QFactoryLoader::QFactoryLoader() looking at "/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0"

  3. "Failed to extract plugin meta data from '/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0'"

  4. not a plugin

  5. QFactoryLoader::QFactoryLoader() looking at "/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0.0.0"

  6. "Failed to extract plugin meta data from '/usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libxcb-xinerama.so.0.0.0'"

  7. not a plugin

  8. QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/bin/platforms" ...

  9. Cannot load library /usr/local/lib/python3.7/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: 無法打開共享對象文件: 沒有那個文件或目錄)

  10. 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

  11. .0: 無法打開共享對象文件: 沒有那個文件或目錄)"

  12. qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

  13. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

  14.  
  15. 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM