兵马逐浪去,将象入海流。炮声震心动,惊起卧龙游。
我的博客园主页 --------- 我的知乎主页 --------- 我的github主页 --------- 我的csdn主页 --------- 我的新浪微博

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

 

posted @ 2021-05-24 10:16  leoking01  阅读(6149)  评论(0编辑  收藏  举报
#back-to-top { background-color: #00CD00; bottom: 0; box-shadow: 0 0 6px #00CD00; color: #444444; padding: 10px 10px; position: fixed; right: 50px; cursor: pointer; }