将Qt示例应用加入Yocto镜像烧录STM32板后启动失败求助
解决方案
1. 修复QtQuick.Layouts插件文件名错误
你执行chmod时用错了插件文件名,实际存在的是libqquicklayoutsplugin.so,而非libqtquicklayoutsplugin.so,正确命令:
chmod 755 /usr/lib/qml/QtQuick/Layouts/libqquicklayoutsplugin.so
2. 确保Weston(Wayland compositor)服务运行
Wayland显示创建失败,说明Weston未启动:
- 检查服务状态:
systemctl status weston - 若未启动,手动启动:
systemctl start weston - 设置开机自启(可选):
systemctl enable weston
3. 修正root用户的环境变量权限问题
root用户运行时,需指定正确的运行时目录,否则会出现权限报错:
export XDG_RUNTIME_DIR=/run/user/0 mkdir -p $XDG_RUNTIME_DIR chmod 0700 $XDG_RUNTIME_DIR
将上述命令添加到run_automotive脚本开头,避免每次手动设置。
4. 补充Yocto构建的依赖包
你的local.conf中缺少qtquicklayouts包,这是QtQuick.Layouts模块的依赖,需添加:
IMAGE_INSTALL:append = " qtquicklayouts"
重新构建镜像并烧录。
5. 检查Qt平台插件依赖
验证Wayland平台插件的依赖库是否完整:
ldd /usr/lib/qt5/plugins/platforms/libqwayland-egl.so
若有缺失的库,需在Yocto的IMAGE_INSTALL中补充对应的包(如wayland-client、wayland-server等,通常meta-qt5会自动依赖,但需确认)。
6. 正确设置Qt平台环境变量
运行应用前指定正确的平台插件,替代offscreen:
export QT_QPA_PLATFORM=wayland-egl
再执行run_automotive。
内容的提问来源于stack exchange,提问作者Neslihan Gültekin
相关产品推荐
相关产品推荐

