欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

This application failed to start because it could not find or load the Qt platform plugin "linuxfb"

程序员文章站 2022-03-31 09:35:32
...

你好!这里是风筝的博客,

欢迎和我一起交流。


在ARM板子上执行QT程序的时候,发现错误:

This application failed to start because it could not find or load the Qt platform plugin "linuxfb"
in "/work/qt/qt_arm".

Available platform plugins are: linuxfb, minimal, offscreen, vnc.

Reinstalling the application may fix this problem.
Aborted

这是因为没有找到linuxfb插件引起的,在QT的安装路径下:plugins/platforms,里面就存在libqlinuxfb.so,我把整个交叉编译过的QT复制到板子上,设置好环境变量:
vi /etc/profile

export QTEDIR=/work/qt/qt_arm
export LD_LIBRARY_PATH=/work/qt/qt_arm/lib:$LD_LIBRARY_PATH
#export QT_QPA_GENERIC_PLUGINS=tslib
#export QT_QPA_FONTDIR=$QTEDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTEDIR/plugins/
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=176x220:mmSize=22x27:offset=0x0:
export QT_PLUGIN_PATH=/work/qt/qt_arm/plugins/

重启之后发现问题依旧没有解决,这样子,只好借助工具查看了!
使用strace:
如果是glibc的话可以从ubuntu下把starce拷出来放到板子上,就可以运行。
或者从网上下载一个别人编译好的strace,直接下载下来用,这里我也放一个下载链接吧,文章末尾提供。
或者是自己去下载strace源码来编译安装得到执行文件。

把stace放到板子根文件系统的bin目录即可。

起初是以为真的找不到linuxfb.so导致的错误,
执行:strace ./hello 2>&1 | grep “linuxfb.so
其中hello是我们的QT程序,发现:

lstat64("/work/qt/qt_arm/plugins/platforms/libqlinuxfb.so", {st_mode=S_IFREG|0755, st_size=721352, ...}) = 0
open("/work/qt/qt_arm/plugins/platforms/libqlinuxfb.so", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3

这表明是可以找到linuxfb.so的,并且成功打开了,那我们这个错误到底是什么呢?
直接执行:
strace ./hello
就会发现真正的错误是:

open("/work/qt/qt_arm/lib/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No s                                                              uch file or directory)
open("tls/v7l/neon/vfp/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such                                                               file or directory)
open("tls/v7l/neon/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such fil                                                              e or directory)
open("tls/v7l/vfp/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file                                                               or directory)
open("tls/v7l/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or                                                               directory)
open("tls/neon/vfp/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such fil                                                              e or directory)
open("tls/neon/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or                                                               directory)
open("tls/vfp/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or                                                               directory)
open("tls/libts-1.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or dire                                                              ctory)

也就是找不到libts-1.0.so.0
这个错误是因为,我交叉编译QT时,因为我没有触摸屏,所以我并没有管 libts 关于触摸这部分,所以导致不能找到libts-1.0.so.0。
最后我在交叉工具链上寻找libts-1.0.so
find -name libts-1.0.so
找到后拷到板子的lib目录下即可

相关标签: qt arm Linux