在 linux 上部署 Qt5.10 App 时出错

Posted

技术标签:

【中文标题】在 linux 上部署 Qt5.10 App 时出错【英文标题】:Error while deploying Qt5.10 App on linux 【发布时间】:2018-08-09 13:03:48 【问题描述】:

我正在尝试在 linux 上手动部署一个简单的示例。

我复制了运行所需的依赖

ldd ./binaryFile

在应用目录内

├── app.sh
├── lib
└── testApp

在我拥有的 lib 目录中

├──lib
  ├── plugins
  ├── qml
  └── other .so files from ldd

然后我运行 bash 脚本

#!/bin/sh
 export LD_LIBRARY_PATH=`pwd`/lib
 export QML_IMPORT_PATH=`pwd`/lib/qml
 export QML2_IMPORT_PATH=`pwd`/lib/qml
 export QT_QPA_PLATFORM_PLUGIN_PATH=`pwd`/lib/plugins/platforms
 #export QT_DEBUG_PLUGINS=0
 ./testApp

但我收到此错误

This application failed to start because it could not find or load the Qt platform plugin "xcb" in "/home/zed/Desktop/testDep/lib/plugins/platforms".

Available platform plugins are: eglfs (from /home/zed/Desktop/testDep/lib/plugins/platforms), linuxfb (from /home/zed/Desktop/testDep/lib/plugins/platforms), minimal (from /home/zed/Desktop/testDep/lib/plugins/platforms), minimalegl (from /home/zed/Desktop/testDep/lib/plugins/platforms), offscreen (from /home/zed/Desktop/testDep/lib/plugins/platforms), vnc (from /home/zed/Desktop/testDep/lib/plugins/platforms), webgl (from /home/zed/Desktop/testDep/lib/plugins/platforms), xcb (from /home/zed/Desktop/testDep/lib/plugins/platforms).

Reinstalling the application may fix this problem. ./app.sh: line 7:  1948 Aborted                 (core dumped) ./testApp

即使“xcb”插件在平台目录中

当我使用它运行时

export QT_DEBUG_PLUGINS=1

我收到此调试消息

Got keys from plugin meta data ("xcb") QFactoryLoader::QFactoryLoader() checking directory path "/home/zed/Desktop/testDep" ... QFactoryLoader::QFactoryLoader() looking at "/home/zed/Desktop/testDep/app.sh" QElfParser: '/home/zed/Desktop/testDep/app.sh' is not an ELF object "'/home/zed/Desktop/testDep/app.sh' is not an ELF object" 
         not a plugin QFactoryLoader::QFactoryLoader() looking at "/home/zed/Desktop/testDep/testApp" "Failed to extract plugin meta data from '/home/zed/Desktop/testDep/testApp'" 
         not a plugin Cannot load library /home/zed/Desktop/testDep/lib/plugins/platforms/libqxcb.so: (/usr/lib/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 "/home/zed/Desktop/testDep/lib/plugins/platforms/libqxcb.so" : "Cannot load library /home/zed/Desktop/testDep/lib/plugins/platforms/libqxcb.so: (/usr/lib/libQt5XcbQpa.so.5: symbol
_ZNK15QPlatformWindow15safeAreaMarginsEv version Qt_5_PRIVATE_API not defined in file libQt5Gui.so.5 with link time reference)" QFactoryLoader::QFactoryLoader() checking directory path "/home/zed/Desktop/testDep/lib/plugins/platforms/platforms" ... QFactoryLoader::QFactoryLoader() checking directory path "/home/zed/Desktop/testDep/platforms" ... This application failed to start because it could not find or load the Qt platform plugin "xcb" in "/home/zed/Desktop/testDep/lib/plugins/platforms".

有没有办法解决这个问题?

PS: Qt 版本:5.10 编译于:Kubuntu 18.4 测试:Manjaro XFCE 17.1

【问题讨论】:

只是在做ldd myBinaryFile | grep xcb,这是我的输出:libxcb-dri3.so.0 => /usr/lib64/libxcb-dri3.so.0 (0x00007fffeda13000) libxcb-present.so.0 => /usr/lib64/libxcb-present.so.0 (0x00007fffed810000) libxcb-sync.so.1 => /usr/lib64/libxcb-sync.so.1 (0x00007fffed608000) libX11-xcb.so.1 => /usr/lib64/libX11-xcb.so.1 (0x00007fffec9a2000) libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fffec77a000) libxcb-glx.so.0 => /usr/lib64/libxcb-glx.so.0 (0x00007fffec55f000) libxcb-dri2.so.0 => /usr/lib64/libxcb-dri2.so.0 (0x00007fffec359000) 对不起格式,我现在不知道如何在评论中添加新行,您可以在文本编辑中复制/粘贴并格式化。 我已经将 ldd binaryFile 中的所有文件复制到了我的 lib 文件夹中,其中只有一个带有 xcb 的文件libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f963ed93000) 【参考方案1】:

两台机器上使用的 Qt 版本似乎不匹配

/home/zed/Desktop/testDep/lib/plugins/platforms/libqxcb.so: (/usr/lib/libQt5XcbQpa.so.5: 它在操作系统库中寻找该文件而不是我提供的库,我将所需文件从 Kubuntu 机器复制到 lib 目录部署机器并解决了问题

【讨论】:

以上是关于在 linux 上部署 Qt5.10 App 时出错的主要内容,如果未能解决你的问题,请参考以下文章

在 Heroku 上部署 React 应用程序和 Nginx 时出现问题

部署 Google App Engine 应用程序时出现 503 错误

在 ZEIT 上部署时出现 MongoDB 连接错误

在 YARN 集群上部署 pyspark 作业时出现 FileNotFoundException

Google App Engine:部署应用程序时出现“错误:没有名为 numpy.distutils.core 的模块”

在heroku上部署应用程序时出现过时的纱线锁文件错误