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

标签 c++ linux qt shared-libraries

我正在尝试在 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".

有办法解决这个问题吗?

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

最佳答案

看来两台机器上使用的 Qt 版本不匹配

/home/zed/Desktop/testDep/lib/plugins/platforms/libqxcb.so: (/usr/lib/libQt5XcbQpa.so.5: It was looking for that file in the OS libs not the libs I provided, I copied the required files from Kubuntu machine to the lib directory deployment machine and that fixed the issue

关于c++ - 在 linux 上部署 Qt5.10 App 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51767824/

相关文章:

c++ - 线程如何运行循环直到加入?

c++ - 如何在不使用 makefile 的情况下链接目标文件和库

c++ - 模板链接问题C++

c++ - 在单个语句中将临时字符串流转换为 c_str()

linux - jssc windows 和 linux

c++ - 寻找合适的数据存储和搜索引擎

linux - 在 bash 中使用变量复制命令

java - ClassNotFoundException : in gnu. gcj.runtime.SystemClassLoader

python - PyQt Bloat 和 Pyinstaller

c++ - 从基方法获取派生类