我尝试在预装了 Qt5.7
的 Ubuntu 16.04 LTS 上启动使用 Qt 编译的二进制文件。5.5
它没有用。
起初,我ldd
按照这里的建议检查了二进制文件本身,并满足了所有“未找到”的依赖项。This application failed to start because it could not find or load the Qt platform plugin "xcb"
然后抛出了这个臭名昭著的错误。
如何在 Linux 中解决这个问题
首先,您应该创建platforms
二进制文件所在的目录,因为它是 Qt 查找 XCB 库的地方。复制libqxcb.so
到那里。我想知道为什么其他答案的作者没有提到这一点。
然后,您可能希望运行QT_DEBUG_PLUGINS=1
设置了环境变量的二进制文件以检查哪些依赖项libqxcb.so
不满足。(您也可以ldd
按照接受的答案中的建议使用此功能)。
命令输出可能如下所示:
me@xerus:/media/sf_Qt/Package$ LD_LIBRARY_PATH=. QT_DEBUG_PLUGINS=1 ./Binary
QFactoryLoader::QFactoryLoader() checking directory path "/media/sf_Qt/Package/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/media/sf_Qt/Package/platforms/libqxcb.so"
Found metadata in lib /media/sf_Qt/Package/platforms/libqxcb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"xcb"
]
},
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 329472
}
Got keys from plugin meta data ("xcb")
loaded library "/media/sf_Qt/Package/platforms/libqxcb.so"
QLibraryPrivate::loadPlugin failed on "/media/sf_Qt/Package/platforms/libqxcb.so" : "Cannot load library /media/sf_Qt/Package/platforms/libqxcb.so: (/usr/lib/x86_64-linux-gnu/libQt5DBus.so.5: version `Qt_5' not found (required by ./libQt5XcbQpa.so.5))"
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
Available platform plugins are: xcb.
Reinstalling the application may fix this problem.
Aborted (core dumped)
注意失败的libQt5DBus.so.5
库。将其复制到您的库路径,在我的情况下,它与我的二进制文件所在的目录相同(因此LD_LIBRARY_PATH=.
)。重复此过程,直到满足所有依赖项。
PS感谢这个答案的作者QT_DEBUG_PLUGINS=1
。