温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》
  • 首页 > 
  • 教程 > 
  • 开发技术 > 
  • Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

发布时间:2020-08-12 15:11:50 来源:亿速云 阅读:1141 作者:小新 栏目:开发技术

小编给大家分享一下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:

$ vim ~/.bashrc

在最末尾添加如下语句,会在qtcreator启动时,列出详细的错误提示。

export QT_DEBUG_PLUGINS=1

如下:

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

保存退出编辑,使配置文件生效:

$ source ~/.bashrc

启动qtcreator会弹出如下详细错误信息:

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

在打印的错误信息的最下面,找到了引发错误的真正原因:

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

也就是Qt动态链接库的问题,当加载libqxcb.so库的时候,还需要加载libxcb-xinerama库。
切换到报错libxcb.so所在目录:

#替换为自己的报错目录
$ cd /home/brainiac/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/

运行ldd libqxcb.so,查看关联内容:

$ ldd libqxcb.so

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

发现不存在libxcb-xinerama.so.0库。

解决方法

安装libxcb-xinerama库:

#如果还存在其他依赖库没有安装,也一并安装。
$ sudo apt-get install libxcb-xinerama0

安装完成后,再次查看关联内容,发现已经修复问题:

$ ldd libqxcb.so

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

再次运行qt程序,就可以正常运行了。

Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办

后记

又可以愉快的coding了。

看完了这篇文章,相信你对Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI