我试图5.7
在5.5
预先安装了Qt的Ubuntu 16.04 LTS上启动使用Qt编译的二进制文件。没用
首先,我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
。