使用Yocto SDK交叉编译Qt6.5时QWayland依赖缺失问题
Yocto SDK交叉编译Qt6.5时QtWayland依赖问题排查
背景信息
已完成Qt主机构建,相关目录定义:
- qt-host:主机构建安装目录
- qt-hostbuild:主机构建构建目录
- qt6-build:设备端构建目录
- qt6-device:设备端安装目录
主机构建命令:
cmake ../qt5/ -GNinja -DFEATURE_developer_build=ON -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$HOME/qt-host
交叉编译配置命令:
../qt5/configure -release -nomake examples -nomake tests -skip qtwebengine -skip qtwebkit -sysroot $HOME/sdk/sysroot/cortexa53-crypto-linux -qt-host-path $HOME/qt-host -extprefix $HOME/qt6-device -prefix /home/qt6 -- -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain.cmake
问题现象
配置设备端构建时,qtwayland模块抛出警告:
CMake Warning at qtwayland/src/CMakeLists.txt:25 (message): QtWayland is missing required dependencies, nothing will be built. Although this could be considered an error, the configuration will still pass as coin (Qt's continuous integration system) will fail the build if configure fails, but will still try to configure the module on targets that are missing dependencies.
在qtwayland的CMakeLists.txt中添加输出后,得到变量值:
[QtWayland] Wayland_FOUND="TRUE" [QtWayland] Wayland_VERSION="1.20.0" [QtWayland] WaylandScanner_FOUND="FALSE"
设备使用Wayland和Weston compositor,wayland-scanner二进制文件位于sysroot/x86_64-linux/usr/bin目录。
问题分析与修复方案
核心问题是CMake无法定位wayland-scanner工具,以下是针对性修复方向:
1. 手动指定WaylandScanner路径
在交叉编译configure命令中直接传入WaylandScanner_EXECUTABLE参数,明确指向sysroot中的工具:
../qt5/configure -release -nomake examples -nomake tests -skip qtwebengine -skip qtwebkit -sysroot $HOME/sdk/sysroot/cortexa53-crypto-linux -qt-host-path $HOME/qt-host -extprefix $HOME/qt6-device -prefix /home/qt6 -- -DCMAKE_TOOLCHAIN_FILE=$HOME/toolchain.cmake -DWaylandScanner_EXECUTABLE=$HOME/sdk/sysroot/x86_64-linux/usr/bin/wayland-scanner
或者在toolchain.cmake中添加配置:
set(WaylandScanner_EXECUTABLE $ENV{HOME}/sdk/sysroot/x86_64-linux/usr/bin/wayland-scanner CACHE FILEPATH "Wayland scanner tool")
2. 配置CMake主机工具搜索路径
交叉编译时需明确区分主机(x86_64)与目标(arm)工具,在toolchain.cmake中添加主机工具目录到搜索路径:
set(CMAKE_SYSROOT $ENV{HOME}/sdk/sysroot/cortexa53-crypto-linux) list(APPEND CMAKE_PROGRAM_PATH "${CMAKE_SYSROOT}/x86_64-linux/usr/bin")
3. 验证wayland-scanner的可执行性
确保工具具备可执行权限,且主机系统能正常运行:
chmod +x $HOME/sdk/sysroot/x86_64-linux/usr/bin/wayland-scanner $HOME/sdk/sysroot/x86_64-linux/usr/bin/wayland-scanner --version
4. 检查Yocto SDK完整性
确认Yocto SDK已包含wayland-native或wayland-scanner-native包,若缺失,需重新生成SDK时添加对应包到SDK配方中。
内容的提问来源于stack exchange,提问作者Michael
相关产品推荐
相关产品推荐

