本文主要是介绍ubuntu安装qt5 Could not load the Qt platform plugin “xcb“ in ““ even though it was found.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
每次在linux安装QT总是会出现各种问题,看了很多博客都不够全面,解决问题花了很大的精力,实属没必要。想写篇尽可能全面的博客记录下来。
QT版本:qt-opensource-linux-x64-5.12.10.run
ubantu版本:18.04桌面版
1、下载
下载地址:https://download.qt.io/archive/qt/5.12/
2、运行安装文件
注意:安装要在系统提供的终端上进行,xshell下无法安装成功
给qt-opensource-linux-x64-5.12.10.run执行权限
chmod +x qt-opensource-linux-x64-5.12.10.run
执行完毕后用ls命令查看qt-opensource-linux-x64-5.12.10.run,确认有执行权限
ls -l qt-opensource-linux-x64-5.12.10.run
此时权限如下所示
3、开始安装
为了跳过QT安装时的登陆账号步骤,安装之前先把网络断开,如果有账号可以不断网。
执行如下命令启动安装程序,安装过程不要关闭终端窗口
./qt-opensource-linux-x64-5.12.10.run
一路下一步,直到选择组件时,最好全选,否则根据用途自行选择
想了解各模块功能的同学,参看如下链接:
Qt Charts:https://blog.csdn.net/u011430225/article/details/79012904
Qt Data Visualization:同上
Qt Purchasing :https://www.cnblogs.com/findumars/p/5574539.html
Virtual Keyboard:同上
安装完成后,就下而已在如下目录中找到QTCreator了(如果不是安装在home根目录,需要进入指定目录)
~/Qt5.12.10/Tools/QtCreator/bin$
4、安装完毕
此时,qt已经安装完毕,尝试启动qtcreator,在ubantu下时无法启动,出现如下问题
找不到xcb库
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.Reinstalling the application may fix this problem.
Aborted (core dumped)
解决方法:
解决方法:
1.sudo gedit ~/.bashrc 输入 export QT_DEBUG_PLUGINS=1 和
export LD_LIBRARY_PATH=/home/itcast/qt/Qt5.12.10/5.12.10/gcc_64/lib:$LD_LIBRARY_PATH(注意把路径替换为自己的安装路径)
2.运行qtcreator,在命令行得到运行中过程,如下
QFactoryLoader::QFactoryLoader() checking directory path "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqeglfs.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/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 ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqlinuxfb.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqlinuxfb.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["linuxfb"]},"archreq": 0,"className": "QLinuxFbIntegrationPlugin","debug": false,"version": 331520
}Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqminimal.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqminimal.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["minimal"]},"archreq": 0,"className": "QMinimalIntegrationPlugin","debug": false,"version": 331520
}Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqminimalegl.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqminimalegl.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["minimalegl"]},"archreq": 0,"className": "QMinimalEglIntegrationPlugin","debug": false,"version": 331520
}Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqoffscreen.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqoffscreen.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["offscreen"]},"archreq": 0,"className": "QOffscreenIntegrationPlugin","debug": false,"version": 331520
}Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqvnc.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqvnc.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["vnc"]},"archreq": 0,"className": "QVncIntegrationPlugin","debug": false,"version": 331520
}Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so"
Found metadata in lib /home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so, metadata=
{"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3","MetaData": {"Keys": ["xcb"]},"archreq": 0,"className": "QXcbIntegrationPlugin","debug": false,"version": 331520
}Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/bin/platforms" ...
loaded library "/home/itcast/qt/Qt5.12.10/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so"
loaded library "Xcursor"
Segmentation fault (core dumped)
3.原因在于libqxcb.so,解决方法:
进入platform目录 : ~/qt/Qt5.12.10/5.12.10/gcc_64/plugins/platforms(注意路径和安装位置有关) 执行如下命令
ldd libqxcb.so
sudo apt install --reinstall libxcb-xinerama0
source ~/.bashrc
到这里QT就已经可以打开了(注意,QT 需要加sudo才能打开)
sudo ./qtcreator
这篇关于ubuntu安装qt5 Could not load the Qt platform plugin “xcb“ in ““ even though it was found.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!