当前位置:网站首页>基于全志H3的QT5.12.9移植教程
基于全志H3的QT5.12.9移植教程
2022-07-01 23:59:00 【冬瓜~】

一. 前言

大学玩了很久的STM32单片机,STM32的MCU大多数是基于Arm Cortex-M3/M4/M7架构的芯片,具有极强的实时处理能力,但MCU相比于MPU而言还是有局限性。相比于MCU,MPU具有更高的处理和运算能力,一般需要运行较大型的操作系统(如:Linux、Andriod)来实现复杂的任务处理,这就决定了MPU应该具备更高的主频和更强大的算力,主要代表:Arm Cortex-A架构的处理器。
为了完成在嵌入式上的进阶,在某宝买到了一块Liunx开发板,处理器为基于ARM Cortex-A7架构的全志H3。项目需要在开发板上运行QT应用,但是商家提供的最小系统中没有QT的运行环境,需要自己移植。
二. 下载链接
开发环境 :Ubuntu 18.04
开发板系统 :精简版Linux3.4
Qt源码 :qt-everywhere-src-5.12.9
Qt Creater:qt-opensource-linux-x64-5.12.9.run
交叉编译器 :gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-guneabi.tar.xz
- 开发板资料(含开发板固件与源码)https://pan.baidu.com/s/1a6F_0xYCsZj9S1xIl0FRmg(密码:amxc)
- Qt Creater与Qt 源码下载链接:https://download.qt.io/archive/qt/
- 交叉编译器官方下载链接:https://releases.linaro.org/components/toolchain/binaries/
- 交叉编译器清华大学镜像站下载链接:https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/_toolchain/
- GLIBC 库官方下载链接:https://sourceware.org/glibc/wiki/Glibc%20Timeline
- Xshell绿色版下载链接 :https://423down.lanzouh.com/b0f2b54tc
其中Qt源码和交叉编译器如果不想直接在官网翻,也可以直接在CSDN下载:
三. 系统编译
更新编译器
Linux系统源码由商家提供,首先解压H3-DVK-lichee-201809.tar
到Ubuntu系统中,Linux源码中的默认交叉编译器版本太低,需要替换成4.9.4版本
的交叉编译器。将解压好的交叉编译器替换掉源码中lichee/brandy/gcc-linaro
的文件夹。

源码编译
首次编译,需要导入默认的内核配置,进入linux3.4
文件夹。执行:
cp H3_defconfig .config
退回到lichee
文件夹,再执行:
./build.sh config
#依次选择 1 1 0 2
#如果提示usbwifi 选择 y
仅首次编译需要 config,以后再次编译只需使用命令
./build.sh
编译成功后,打包固件:
./build.sh pack
# 固件位置:tools/pack/sun8iw7p1_dragonboard_dolphin.img
四. QT源码编译
添加编译器路径
解压Qt源码到Ubuntu系统,修改文件内容:
路径:qt-everywhere-src-5.12.9/qtbase/linux-arm-gnueabi-g++/qmake.conf
目的:主要是为了指定编译Qt源码的编译器路径,这里选择刚刚复制到lichee源码中的编译器。
#
# qmake configuration for building with arm-linux-gnueabi-g++
# MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-gcc
QMAKE_CXX = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-g++
QMAKE_LINK = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-objcopy
QMAKE_NM = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-nm -P
QMAKE_STRIP = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-strip
load(qt_config)
配置、编译、安装
进入qt-everywhere-src-5.12.9
目录创建config.sh
配置脚本,内容为:
./configure \
-prefix /home/dell/qt_install \
-xplatform linux-arm-gnueabi-g++ \
-confirm-license \
-opensource \
-release \
-shared \
-qt-zlib \
-qt-freetype \
-sql-sqlite \
-qt-libjpeg \
-no-qml-debug \
-no-dbus \
-no-gif \
-no-iconv \
-no-opengl \
-no-cups \
-no-glib \
-no-rpath \
-no-avx \
-no-openssl \
-nomake tools \
-qt-libpng \
-no-tslib \
其中,-prefix /home/dell/qt_install
为指定的Qt库安装路径,-xplatform linux-arm-gnueabi-g++
为指定编译器,其余选项可以根据自己的需求来增减Qt组件,适当剪裁。
修改执行权限
chmod 777 config,sh
执行配置
./config.sh
编译源码
make -j16
安装Qt
make install
安装完成后,编译得到的Qt库就在/home/dell/qt_install
中。
五. QT移植与环境变量添加
将上一步编译得到的Qt库,即/home/dell/qt_install
,整个文件夹复制到lichee/buildroot/target/dragonboard/rootfs/opt/
中。

修改lichee/buildroot/target/dragonboard/extra/profile
,添加全局变量:
export LD_LIBRARY_PATH=/opt/qt_install/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/qt_install/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
修改完成后重新编译linux,打包系统。
./build.sh
./build.sh pack
六. 升级GLIBC
将上一步打包得到的固件烧录进开发板,使用Xshell
串口连接开发板打开终端,进入opt/qt_install/example
目录,随便打开一个Qt示例,执行对应文件夹下的可执行文件。
Qt执行报错,这是由于我们更换了更高版本的交叉编译器,系统源码里原本的C/C++库就不支持了。
可以在对应文件夹下执行如下命令查看对应版本号:
strings libstdc++.so.6 | grep CXXABI # 在/usr/lib中执行,查看CXXABI版本号
strings libc.so.6 | grep GLIBC # 在/lib中执行,查看GLIBC版本号

我们需要将新的编译器中对应的库文件移植进系统中。对应库文件在gcc-linaro/arm-linux-gnueabi/libc
下。
这里粗暴得将该目录下的文件全部复制到lichee/buildroot/target/dragonboard/rootfs/lib/
以及lichee/buildroot/target/dragonboard/rootfs/usr/lib/
中,覆盖同名的库。
七. 运行QT程序
成功升级库后,再次跑Qt案例中的可执行文件,成功跑通,至此Qt.5.12.9移植成功。

八. 参考资料
边栏推荐
- ConcurrentSkipListMap——跳表原理
- 【模板】自适应辛普森积分
- Deep learning | three concepts: epoch, batch, iteration
- 门级建模—课后习题
- 启牛学院开户安全的吗?开户怎么开?
- JPA handwritten SQL, received with user-defined entity classes
- [QT] QT cannot find a solution to the compiler using msvc2017
- vue 强制清理浏览器缓存
- openwrt 开启KV漫游
- Write some suggestions to current and future doctoral students to sort out and share
猜你喜欢
使用 pair 做 unordered_map 的键值
Review data desensitization system
Selectively inhibiting learning bias for active sampling
回顾数据脱敏系统
Jielizhi, production line assembly link [chapter]
Use pair to do unordered_ Key value of map
- Oui. Env. Fichier XXX, avec constante, mais non spécifié
PWN attack and defense world cgpwn2
Material design component - use bottomsheet to show extended content (I)
Redis master-slave synchronization
随机推荐
. env. XXX file, with constant, but undefined
回顾数据脱敏系统
ERP项目施行计划的目的是什么?
RPA tutorial 01: Excel automation from introduction to practice
电商RPA机器人,助力品牌电商抢立流量高点
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
ConcurrentSkipListMap——跳表原理
正则表达式收集
Write some suggestions to current and future doctoral students to sort out and share
GCC compilation
Correlation - intra group correlation coefficient
Use pair to do unordered_ Key value of map
RPA教程01:EXCEL自动化从入门到实操
leetcode96不同的二叉搜索树
二叉搜索树的创建,查找,添加,删除操作
使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
Shell process control
Key points of security agreement
Various global files related to [.Net core] program
Difficult to get up syndrome (bit by bit greed)