环境介绍:
- Host:ubuntu 18.04
- 交叉编译器: linux-arm-gnueabihf-gcc
- TargetBorad :A33
- QT版本:Qt5.9.6
1. 文件系统环境准备
1.1 参考《A33 ubuntu-base构建arm文件系统》构建ubuntu文件系统rootfs
1.2 文件系统安装必要的软件包
sudo cp -af rootfs sysroot
./ch-mount.sh -m sysroot/
apt-get install libc6-dev libstdc++6 pkg-config libudev-dev
1.3 因为支持eglfs,需要将gpu的库和头文件预置到文件系统中
sudo cp -rfd gpu/lib/* sysroot/usr/lib/arm-linux-gnueabihf/
sudo cp -rfd gpu/include/* sysroot/usr/include/
1.4 文件系统库路径重定向
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./ch-mount.sh -u sysroot/
sudo ./sysroot-relativelinks.py sysroot
2.下载qt源码并解压
wget https://download.qt.io/archive/qt/5.9/5.9.6/single/qt-everywhere-opensource-src-5.9.6.tar.xz
tar -xJvf qt-everywhere-opensource-src-5.9.6.tar.xz
3.下载交叉工具链并解压,申明工具链路径
wget http://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/arm-linux-gnueabihf/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz
sudo tar -xJvf gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf.tar.xz -C /opt
export PATH=$PATH:/opt/gcc-linaro-5.3.1-2016.05-x86_64_arm-linux-gnueabihf/bin
arm-linux-gnueabihf-gcc -v
mkspecs添加linux-arm-gnueabihf
cd qt-everywhere-opensource-src-5.9.6/qtbase/mkspecs/
cp linux-arm-gnueabi-g++ linux-arm-gnueabihf-g++ -rfd
cd linux-arm-gnueabihf-g++
vi qmake.conf
QMAKE_INCDIR_POST += \
$$[QT_SYSROOT]/usr/include \
$$[QT_SYSROOT]/usr/local/include \
$$[QT_SYSROOT]/usr/include/arm-linux-gnueabihf \
QMAKE_LIBDIR_POST += \
$$[QT_SYSROOT]/usr/lib \
$$[QT_SYSROOT]/usr/local/lib \
$$[QT_SYSROOT]/usr/lib/arm-linux-gnueabihf \
$$[QT_SYSROOT]/lib/arm-linux-gnueabihf \
QMAKE_RPATHLINKDIR_POST += \
$$[QT_SYSROOT]/usr/lib \
$$[QT_SYSROOT]/usr/local/lib \
$$[QT_SYSROOT]/usr/lib/arm-linux-gnueabihf \
$$[QT_SYSROOT]/lib/arm-linux-gnueabihf \
若需更改交叉工具链名称,需要在qmake.conf更改,这里是将arm-linux-gnueabi更改为arm-linux-gnueabihf
4.建立编译目录,编写编译脚本autorun.sh
mkdir buildQt596
cd buildQt596
vi autorun.sh
#! /bin/bash
../qt-everywhere-opensource-src-5.9.6/configure \
-sysroot /home/jonlee/work/a33/sysroot \
-extprefix /opt/EmbeddedUbuntuEglfs-Qt5.9.6 \
-confirm-license \
-opensource \
-release \
-make libs \
-xplatform linux-arm-gnueabihf-g++ \
-pch \
-pkg-config \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-dbus \
-no-opengl \
-opengl es2 \
-eglfs \
-no-separate-debug-info \
-linuxfb \
-recheck-all
5.编译,安装
./autorun.sh
make -j16
make install
编译完成后目录如下:
bin examples lib plugins doc include mkspecs qml translations
目标主机只需要lib qml plugins, profile申明QT环境变量
QT_ROOT=/opt/EmbeddedEglfs-Qt5.9.6
export QML2_IMPORT_PATH=$QT_ROOT/qml
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_EGLFS_FB=/dev/fb0
export QT_QPA_EGLFS_INTEGRATION=eglfs_mali
export QT_QPA_EGLFS_PHYSICAL_WIDTH=800
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=480
export QT_QPA_EGLFS_WIDTH=800
export QT_QPA_EGLFS_HEIGHT=480
export QT_QPA_PLATFORM=eglfs
export QT_QPA_EGLFS_ROTATION=90/-90/0/180
#export QT_VIRTUALKEYBOARD_PINYIN_DICTIONARY=$QT_ROOT/qtvirtualkeyboard/pinyin/dict_pinyin.dat
export QT_QPA_FONTDIR=/opt/Embedded-Qt5.9.6/lib/fonts
export LD_LIBRARY_PATH=$QT_ROOT/lib:$QT_ROOT/plugins/imageformats:$LD_LIBRARY_PATH
6.移植过程中遇到的问题及解决方法
6.1 EGL library doesn’t support Emulator extensions
export QT_QPA_EGLFS_INTEGRATION=none
6.2 Unable to query physical screen size, defaulting to 100 dpi.
To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
export QT_QPA_EGLFS_PHYSICAL_WIDTH=480
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=800
6.3 EGL Error : Could not create the egl surface: error = 0x300b
export QT_QPA_EGLFS_INTEGRATION=eglfs_mali
6.4 eglInitialize清屏黑屏
export MALI_NOCLEAR=1
6.5 arm-linux-gnueabihf/bin/ld: cannot find crti.o: 没有那个文件或目录
apt-get install libc6-dev
6.6 ERROR: Feature ‘pkg-config’ was enabled, but the pre-condition ‘tests.pkg-config’ failed.
apt-get install pkg-config