Ubuntu18.04下解决Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“问题

作者:盼小辉丶 时间:2023-08-05 08:21:07 

问题描述

安装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了。

来源:https://blog.csdn.net/LOVEmy134611/article/details/107212845

标签:Ubuntu18.04,Qt,qt.qpa.plugin
0
投稿

猜你喜欢

  • 论策:浅谈中小企业面临网络营销几大难题

    2009-06-16 09:01:00
  • 谷歌中国宣布翻译工具全新改版 增多种功能

    2009-11-27 14:30:00
  • 加一道防护网:Win2008的高级防火墙

    2009-08-29 10:06:00
  • 四步使您的页面浏览量突破每天一千人次[译]

    2009-07-20 17:06:00
  • QQ域名邮箱再升级 每个号最多绑定5个域名

    2009-09-29 09:22:00
  • WordPress Blog模版设计教程(图)

    2010-03-21 15:18:00
  • 于丹推荐《研祥-再造非经典》为金融危机护航

    2009-10-14 16:34:00
  • 站长策划网站 抓住四点不要放松

    2009-03-02 18:04:00
  • Exchange 2003设计和体系结构

    2010-02-21 19:08:00
  • 浪费资源无点点击 应对反盗链技术的途径

    2008-12-25 10:51:00
  • Fishman的创业经验分享

    2007-09-08 08:19:00
  • 雨林木风115网络U盘 大容量新政策吸引用户

    2009-11-26 13:56:00
  • SEO前景,SEM前景,网络营销前景

    2009-09-13 11:51:00
  • 戴志康:80后完全无包袱,更容易成功

    2007-10-31 21:39:00
  • 防黑 加强Linux安全管理的方法

    2009-06-05 13:41:00
  • 网络赚钱找准自己的方向

    2009-08-10 18:27:00
  • 网站吸引百度收录的三种最有效的方法

    2008-11-30 18:38:00
  • 保护(IIS)web服务器的15个技巧

    2008-04-18 16:01:00
  • asp.net RewritePath重定向HTTP头Content-Location暴露真实路径解决方法

    2022-01-15 22:04:27
  • 雅虎优化:次级页面、主域名与网页级别

    2007-09-23 08:29:00
  • asp之家 网站运营 m.aspxhome.com