英文:
Ubuntu 22.04 & Qt 6.5 : qt.qpa.plugin Could not load the Qt platform plugin "xcb" in "" even though it was found
问题
当我安装了Ubuntu 22.04
和Qt 6.5.2
后,我遇到了一个错误,阻止了我的所有项目运行,并且没有像预期的那样显示输出。
qt.qpa.plugin: 无法加载Qt平台插件“xcb”在“”中
即使找到了也是如此。这个应用程序启动失败,因为没有Qt
平台插件可以初始化。重新安装应用程序可能会
解决这个问题。可用的平台插件有:vnc、minimal、wayland-egl、offscreen、
xcb、vkkhrdisplay、eglfs、minimalegl、linuxfb、wayland。
我检查了/home/username/Qt/6.5.2/gcc_64/plugins/platforms/
路径,并了解到所有文件都是正确的。
我还尝试了:
export QT_QPA_PLATFORM_PLUGIN_PATH=/home/username/Qt/6.5.2/gcc_64/plugins/platforms/
但没有帮助。
英文:
As I installed Ubuntu 22.04
and Qt 6.5.2
, I encountered an error that prevented any of my projects from running, and it did not display the output as expected.
> 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: vnc, minimal, wayland-egl, offscreen,
> xcb, vkkhrdisplay, eglfs, minimalegl, linuxfb, wayland.
I checked the /home/username/Qt/6.5.2/gcc_64/plugins/platforms/
path and underestand that all files were correct.
I also try:
export QT_QPA_PLATFORM_PLUGIN_PATH=/home/username/Qt/6.5.2/gcc_64/plugins/platforms/
But it didnt help.
答案1
得分: 2
为了解决这个问题,在运行环境的“Build Environment”部分中,我添加了QT_DEBUG_PLUGINS = 1。
这帮助我记录并查看实际发生的情况。
从这个错误消息中:
qt.core.plugin.factoryloader: checking directory path "/home/parisa/build-untitled1-Desktop_Qt_6_5_2_GCC_64bit-Debug/platforms" ...
qt.core.library: "/home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so" cannot load: Cannot load library /home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so" : "Cannot load library /home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)"
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.
我理解我需要安装libxcb-cursor:
sudo apt-get install libxcb-cursor0
请注意,这只发生在Qt 6.5及以上版本,之前我没有这个问题。
英文:
To Fix this issue I add QT_DEBUG_PLUGINS = 1 in run section Build Environment
This helps me to log and see what actually happens.
from this
qt.core.plugin.factoryloader: checking directory path "/home/parisa/build-untitled1-Desktop_Qt_6_5_2_GCC_64bit-Debug/platforms" ...
qt.core.library: "/home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so" cannot load: Cannot load library /home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so" : "Cannot load library /home/parisa/Qt/6.5.2/gcc_64/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)"
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.
I underestand I need to install libxcb-cursor
sudo apt-get install libxcb-cursor0
Note that this happens only in Qt 6.5 above I didnt have this problem before.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论