五个月前,我从 Ubuntu 16.04 升级到了 Ubuntu 18.04。升级后,几个 Qt 应用程序对我来说不再起作用。我无法启动,而是看到以下错误:
$ git cola &
[1] 9534
$ 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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Reinstalling the application may fix this problem.
error: git-cola died of signal 6
^C
[1]+ Exit 134 git cola
(我考虑在 Ask Ubuntu 上询问这个问题,因为这是我的操作系统,但它可能是 Linux 上更广泛的 Qt 环境问题,所以我应该从这里开始。这不是 git-cola 特有的,因为我在其他应用程序上看到了非常相似的消息。)
网络上有几篇帖子暗示可能缺少相关包,但到目前为止我还无法确定是什么。使用export QT_DEBUG_PLUGINS=1
set 运行会提供更多调试信息,但据我所知没有答案:
$ export QT_DEBUG_PLUGINS=1
$ git-cola
QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/bin/platforms/libqeglfs.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"eglfs"
]
},
"className": "QEglFSIntegrationPlugin",
"debug": false,
"version": 329989
}
...<trimming out the rest of the OK stuff until we reach>...
Got keys from plugin meta data ("xcb")
Cannot load library /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: symbol _ZNK15QPlatformWindow15safeAreaMarginsEv version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)
QLibraryPrivate::loadPlugin failed on "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so" : "Cannot load library /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: symbol _ZNK15QPlatformWindow15safeAreaMarginsEv version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)"
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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Reinstalling the application may fix this problem.
Aborted (core dumped)
当我运行应用程序ldd
或检查应该提供的包时西卡一切看上去都存在并且正确。
$ env LANG=C ldd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
linux-vdso.so.1 (0x00007ffc489e3000)
libQt5XcbQpa.so.5 => /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 (0x00007fd3090c8000)
libQt5Gui.so.5 => /lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007fd308919000)
libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007fd3081de000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd307e50000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd307a5f000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fd307749000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fd307504000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fd307250000)
libQt5DBus.so.5 => /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5 (0x00007fd306fc6000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd306da7000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fd306ba5000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fd30686c000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fd30665c000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fd306454000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fd306239000)
libxcb-xkb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-xkb.so.1 (0x00007fd30601d000)
libxcb-render-util.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render-util.so.0 (0x00007fd305e19000)
libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007fd305c0c000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007fd305a05000)
libxcb-xfixes.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007fd3057fd000)
libxcb-xinerama.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xinerama.so.0 (0x00007fd3055fa000)
libxcb-randr.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-randr.so.0 (0x00007fd3053ea000)
libxcb-image.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-image.so.0 (0x00007fd3051e5000)
libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007fd304fe2000)
libxcb-keysyms.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-keysyms.so.1 (0x00007fd304ddf000)
libxcb-icccm.so.4 => /usr/lib/x86_64-linux-gnu/libxcb-icccm.so.4 (0x00007fd304bda000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fd3049b2000)
libxcb-shape.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007fd3047ae000)
libxkbcommon-x11.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon-x11.so.0 (0x00007fd3045a6000)
libxkbcommon.so.0 => /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0 (0x00007fd304367000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd303fc9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd303db1000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007fd303b25000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd303908000)
libicui18n.so.56 => /lib/x86_64-linux-gnu/libicui18n.so.56 (0x00007fd30346f000)
libicuuc.so.56 => /lib/x86_64-linux-gnu/libicuuc.so.56 (0x00007fd3030b7000)
libicudata.so.56 => /lib/x86_64-linux-gnu/libicudata.so.56 (0x00007fd3016d4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd3014d0000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fd3012ce000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd3095ce000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fd30105c000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fd300e2a000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fd300bf8000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007fd3009ab000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fd300799000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fd300592000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fd30037d000)
libxcb-util.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-util.so.1 (0x00007fd300177000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fd2fff73000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fd2ffd6d000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007fd2ffb3c000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007fd2ff886000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007fd2ff602000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd2ff3fa000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fd2ff1d4000)
liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fd2fefb8000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007fd2fec9d000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007fd2fea88000)
我遇到问题的几个应用程序提供了单独的容器或包装解决方案,例如折断或者扁平包装。虽然这在很多情况下为我提供了一种解决方法,但我仍然希望能够解决我的 Qt 环境的问题。
答案1
看起来您的 Qt 库版本不匹配。
我看到 Qt 库来自/usr/bin/platforms/libqeglfs.so
和
/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms
,它们可能不一致。
您可能需要像这样指定路径:
export LD_LIBRARY_PATH=/path/to/right/libs:$LD_LIBRARY_PATH
答案2
现在 TeamViewer 15 也遇到了类似的问题。在额外安装了一些多媒体包以及 MATLAB 之后,TeamViewer 客户端出现无法启动的问题。
有时在 /var/log/messages 中会出现以下信息:
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.#012#012
Available platform plugins are: xcb.
执行 strace 时总是尝试将其写入此系统日志!
如果正在运行
QT_DEBUG_PLUGINS=1 strace teamviewer
您可以看到 TeamViewer 尝试在日志中报告此情况。与消息中相同的打印输出也出现在 中~/.local/share/teamviewer15/logfiles/gui.log
,但在进行此实验时它不是持久的。
实际问题是/opt/teamviewer/tv_bin/RTlib/qt/plugins/platforms/libqxcb.so
动态加载时有一个未满足的要求。通过命令检查
ldd /opt/teamviewer/tv_bin/RTlib/qt/plugins/platforms/libqxcb.so
你得到
/opt/teamviewer/tv_bin/RTlib/qt/plugins/platforms/libqxcb.so: /usr/lib64/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by /opt/teamviewer/tv_bin/RTlib/qt/plugins/platforms/libqxcb.so) /opt/teamviewer/tv_bin/RTlib/qt/plugins/platforms/libqxcb.so: /usr/lib64/libQt5Gui.so.5: version `Qt_5_PRIVATE_API' not found (required by /opt/teamviewer/tv_bin/RTlib/qt/plugins/platforms/libqxcb.so)
...
ldd 动态加载需求由 .bashrc 中的环境变量设置控制
export LD_LIBRARY_PATH=/usr/lib64
删除环境变量设置后问题自行解决LD_LIBRARY_PATH
,.bashrc
以便在运行 TeamViewer 时动态加载和 ldd 找不到该库!