Qt Creator远程部署qt应用程序到开发板,报错 qt.qpa.plugin: Could not find the Qt platform plugin “eglfs“ in ““

40 篇文章 0 订阅


前言

Qt Creator远程部署程序到Linux开发板,按照文档都配置好以后,点击运行报如下错误。

09:55:40: Starting /opt/test1/bin/test1 on atk-dlrk3568-device...
qt.qpa.plugin: Could not find the Qt platform plugin "eglfs" in ""
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, minimal, offscreen, vnc, wayland-egl, wayland.

网上找了很多方法,都没有效果。

经测试,如下方法管用,记录一下。


一、现象

  • 根据如下输出,可以确定程序已经编译通过,且已经拷贝到开发板中。到开发板中的确也能找程序。
09:55:40: Starting /opt/test1/bin/test1 on atk-dlrk3568-device...
  • 开发板中程序可以运行,说明编译器没问题。
root@ATK-DLRK356X:/opt/test1/bin# ./test1
QStandardPaths: runtime directory '/var/run' is not a directory, but a symbolic link to a directory permissions 0755 owned by UID 0 GID 0

  • 根据报错猜测是板子中没有eglfs这个 plugin,但是Qt Creator默认使用eglfs.
Could not find the Qt platform plugin "eglfs" in ""
  • 到开发板中查找Qt相关的库文件,可以看到的确没有eglfs,有其他6个(linuxfb, minimal, offscreen, vnc, wayland-egl, wayland.)。

在这里插入图片描述

  • 查看开发板的QT_QPA_PLATFORM环境变量是wayland,说明开发板默认使用的是wayland.

在这里插入图片描述

二、解决方法

  • Qt Creator修改默认plugin为wayland,添加QT_QPA_PLATFORM环境变量。

在这里插入图片描述

  • 修改后编译,又报错:error: XDG_RUNTIME_DIR not set in the environment.

在这里插入图片描述

  • 再添加XDG_RUNTIME_DIR环境变量。值我试了两个,有一个不行
XDG_RUNTIME_DIR=/run/user/1000	# 失败
XDG_RUNTIME_DIR=/var/run/		#成功,这就是在开发板中直接跑提示的那个路径

在这里插入图片描述

  • 最后的环境变量配置如下(注意:只添加红框中的内容即可,其他都是系统默认的,不用修改):

在这里插入图片描述

  • 在点击绿色运行按钮,开发板屏幕上就有程序运行了。

总结:

  • 系统环境变量批量编辑中添加如下内容:
QT_QPA_PLATFORM=wayland
XDG_RUNTIME_DIR=/var/run/

在这里插入图片描述

在这里插入图片描述

  • 如果板子里直接运行程序还是报错,但是程序运行正常。那有可能是板子里的XDG_RUNTIME_DIR的值为/var/run,少了一个/,改为XDG_RUNTIME_DIR=/var/run/即可
export XDG_RUNTIME_DIR=/var/run/
  • 或是直接修改设置这个环境变量的地方,例如我的板子是/etc/profile.d/weston.sh中修改
  • 1
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值