1.问题描述:
error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
在使用韦东山imx6ull pro开发板遇到的如上问题。
首先在Ubuntu中使用qt编写了最简单的helloworld程序,下载到开发板上运行,报如上错误。
大概意思就是缺少库文件。
2.补充缺失库文件
于是在开发板使用ldd命令查看 01_helloworld 程序 看看还缺少哪些库文件。
[root@100ask:/mnt]# ldd ./helloworld
linux-vdso.so.1 (0x7ee6a000)
libatomic.so.1 => /lib/libatomic.so.1 (0x76f26000)
libQt5Widgets.so.5 => not found
libQt5Gui.so.5 => not found
libQt5Core.so.5 => not found
libGLESv2.so.2 => not found
libpthread.so.0 => /lib/libpthread.so.0 (0x76efc000)
librt.so.1 => /lib/librt.so.1 (0x76ee5000)
libdl.so.2 => /lib/libdl.so.2 (0x76ed2000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x76dc4000)
libm.so.6 => /lib/libm.so.6 (0x76d5a000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x76d2b000)
libc.so.6 => /lib/libc.so.6 (0x76bea000)
/lib/ld-linux-armhf.so.3 (0x76f3b000)
上述显示not found的均为缺少的库文件。
这些库文件需要在Ubuntu指定目录中查找。我的实际有效目录是Buildroot_2020.02.x,该目录下有我用时两天编译过的根文件系统,请各位根据你自己实际制作的根文件系统来选择目录。
选取Buildroot_2020.02.x/output/build/目录中的库文件,并拷贝到~/nfs_rootfs/目录中用于开发板挂载使用。该库文件最终要拷贝到开发板的/usr/lib/目录中。
book@100ask:~$ find ~/100ask_imx6ull-sdk_bakeup/ -name libQt5Widgets.so.5
/home/book/100ask_imx6ull-sdk_bakeup/Buildroot_2020.02.x/output/build/qt5base-5.12.8/lib/libQt5Widgets.so.5
/home/book/100ask_imx6ull-sdk_bakeup/Buildroot_2020.02.x/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libQt5Widgets.so.5
/home/book/100ask_imx6ull-sdk_bakeup/Buildroot_2020.02.x/output/target/usr/lib/libQt5Widgets.so.5
/home/book/100ask_imx6ull-sdk_bakeup/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libQt5Widgets.so.5
book@100ask:~$ cp /home/book/100ask_imx6ull-sdk_bakeup/Buildroot_2020.02.x/output/build/qt5base-5.12.8/lib/libQt5Widgets.so.5 ~/nfs_rootfs/
同理针对其他缺失库文件做同样操作。
3.开发板可执行程序同级目录下创建platform目录并拷贝相关库文件
拷贝之后再次执行程序,如下提示。
[root@100ask:/mnt]# ./01_helloworld
qt.qpa.plugin: Could not find the Qt platform plugin "linuxfb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
?借用网上的解释:
?我的操作如下:
找到qt安装目录并进入如下路径,找到该库文件。
?然后在~/nfs_rootfs路径下创建同名目录platforms,在该目录里面增加libqlinuxfb.so库文件。
这里要说明一下,01_helloworld是给开发板使用的,nfs_rootfs是开发板的挂载目录。
?在开发板上挂载nfs_rootfs目录,再次运行./01_helloworld程序,结果报同样的错误。
4.打开QT调试打印信息功能
借用网上的描述:
方法如下:
在开发板操作
[root@100ask:/mnt]# vi /etc/profile
?打开后的文件增加一行语句,用于打开QT调试信息打印功能。
export QT_DEBUG_PLUGINS=1
?保存退出,并重启开发板。
再次挂载nfs_rootfs目录,并执行./01_helloworld程序,会有详细报错。
[root@100ask:/mnt]# ./01_helloworld
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/mnt/platforms/libqlinuxfb.so"
Found metadata in lib /mnt/platforms/libqlinuxfb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"linuxfb"
]
},
"archreq": 0,
"className": "QLinuxFbIntegrationPlugin",
"debug": false,
"version": 330752
}
Got keys from plugin meta data ("linuxfb")
Cannot load library /mnt/platforms/libqlinuxfb.so: (libQt5DBus.so.5: cannot open shared object file: No such file or directory)
QLibraryPrivate::loadPlugin failed on "/mnt/platforms/libqlinuxfb.so" : "Cannot load library /mnt/platforms/libqlinuxfb.so: (libQt5DBus.so.5: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "linuxfb" 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.
Available platform plugins are: linuxfb.
Aborted
其中提示缺失库文件libQt5DBus.so.5,这才是问题所在。
Cannot load library /mnt/platforms/libqlinuxfb.so: (libQt5DBus.so.5: cannot open shared object file: No such file or directory)
5.在开发板上继续补充缺失库文件
同最开始的操作,需要在Ubuntu指定目录中查找。选取Buildroot_2020.02.x/output/build/目录中的库文件,并拷贝到~/nfs_rootfs/目录中用于开发板挂载使用。该库文件最终要拷贝到开发板的/usr/lib/目录中。
再次执行./01_helloworld程序,有如下成功提示。
[root@100ask:/mnt]# ./01_helloworld
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/mnt/platforms/libqlinuxfb.so"
Found metadata in lib /mnt/platforms/libqlinuxfb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
"MetaData": {
"Keys": [
"linuxfb"
]
},
"archreq": 0,
"className": "QLinuxFbIntegrationPlugin",
"debug": false,
"version": 330752
}
Got keys from plugin meta data ("linuxfb")
loaded library "/mnt/platforms/libqlinuxfb.so"
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.input: xkbcommon not available, not performing key mapping
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/styles" ...
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/iconengines" ...
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/imageformats" ...
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/mnt/accessible" ...
同时,可见开发板显示了helloworld界面。
6.屏蔽QT调试打印信息功能。
如上调试完毕,可以把QT调试打印信息功能关闭。
重启开发板,再次运行./helloworld程序,只有如下打印信息。
[root@100ask:/mnt]# ./01_helloworld
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.input: xkbcommon not available, not performing key mapping
至此完毕。?
7.补充说明
在做QT操作前,需要先将开发板原有QT GUI移除。
“新版lvgl关闭gui是移除S32lvgl和S49lvgl即可”
参考:
Linux下同时运行不同版本的qt程序 - findumars - 博客园
QT程序在开发板运行问题/ # libQt5Widgets.so.5: cannot open shared object file-OpenEdv-开源电子网
Ubuntu18.04下,QT5移植到ARM板上运行程序发生异常:could not find or load the Qt platform plugin "linuxfb"原因_chaoshuaihaohao的博客-CSDN博客_arm下qt报缺linuxfb
error while loading shared libraries:libQt5SerialPort.so问题解决 - 我的黑铁时代 - 博客园
|