报错内容:
~/Qt5.12.12/Tools/QtCreator/bin$ ./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.
已放弃 (核心已转储)
解决方法:
发现是Qt加载插件出现问题,通过设置QT_DEBUG_PLUGINS=1
,可以查看Qt的插件加载信息。
所以先设置环境变量:
export QT_DEBUG_PLUGINS=1
再次运行程序时,会打印出很多信息,重点是最后一段:
Cannot load library /home/imu/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /home/imu/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so))
QLibraryPrivate::loadPlugin failed on "/home/imu/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/imu/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /home/imu/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforms/libqxcb.so))"
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.
已放弃 (核心已转储)
在目录/Qt5.12.12/5.12.12/gcc_64/lib找到对应的文件libQt5XcbQpa.so.5
复制到目录/计算机/usr/lib/x86_64-linux-gnu覆盖掉原有重名文件
此过程可以使用 sudo nautilus 进入ubuntu 文件管理器,随意复制,删除,粘贴,无权限限制
问题原因:
qt冲突,因为系统本身有一个qt5.9.2版本,而又装了qt5.12.12,因此打包之后会有库冲突,所以根据提示错误,在系统里搜索对应的库,在qt安装目录的库,对应复制到程序lib文件夹下即可。
参考链接:
https://www.jb51.net/article/193024.htm
PyQt5:解决qt.qpa.plugin: Could not load the Qt platform plugin "xcb"错误 - 简书
Error on execution -version `Qt_5' not found required by_Chasing Freedom-CSDN博客