😁博客主页😁:🚀https://blog.csdn.net/wkd_007🚀
🤑博客内容🤑:🍭嵌入式开发、Linux、C语言、C++、数据结构、音视频🍭
⏰发布时间⏰:
本文未经允许,不得转发!!!
🎄一、问题描述
问题描述:在 Ubuntu18.04
安装完 QT5.12.12
后,运行qtcreator
,出现如下报错:
$ qtcreator
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.
已放弃 (核心已转储)
🎄二、分析问题
从打印来看,是没能加载平台插件xcb导致的,那为什么会导致这个问题呢?可以先打开QT调试选项来查看更多的错误信息。
-
1、打开 qt debug 选项
export QT_DEBUG_PLUGINS=1
-
2、再次运行 qtcreator
出现比较多的错误信息:$ qtcreator QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms" ... QFactoryLoader::QFactoryLoader() looking at "/opt/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqeglfs.so" Found metadata in lib /opt/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqeglfs.so, metadata= { "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3", "MetaData": { "Keys": [ "eglfs" ] }, "archreq": 0, "className": "QEglFSIntegrationPlugin", "debug": false, "version": 331520 } .... Got keys from plugin meta data ("xcb") QFactoryLoader::QFactoryLoader() checking directory path "/opt/Qt5.12.12/Tools/QtCreator/bin/platforms" ... Cannot load library /opt/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: 无法打开共享对象文件: 没有那个文件或目录) QLibraryPrivate::loadPlugin failed on "/opt/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /opt/Qt5.12.12/Tools/QtCreator/lib/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, xcb. 已放弃 (核心已转储)
从这些错误信息来看,好像是加载
libqxcb.so
时失败了,没有找到libxcb-xinerama.so.0
,如下图所示:
-
3、再进一步分析,到所在目录去执行
ldd libqxcb.so
,查看其所需要的依赖库,可以确定缺少了libxcb-xinerama.so.0
库文件,如下图:
🎄三、解决方法
安装 libxcb-xinerama0, 这是 X Window System的库,用于启用多显示器支持。执行下面命令安装:
sudo apt-get install libxcb-xinerama0
再使用 ldd 查看libqxcb库,发现已经不缺少相关库了。
ldd libqxcb.so
最后,再运行 qtcreator 就正常了
🎄四、总结
👉本文介绍解决qtcreator运行问题的过程:qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it was found.
如果文章有帮助的话,点赞👍、收藏⭐,支持一波,谢谢 😁😁😁