i.MX6ULL应用移植 | 移植Qt 5.12.9到imx6ull并搭建qt creator开发环境

环境说明

  • 编译器:arm-linux-gnueabihf-gcc 7.5.0
  • OS:ubuntu 20.04

一、下载qt源码

qt下载地址:https://download.qt.io/archive/qt/5.12/5.12.9/single/

wget https://download.qt.io/archive/qt/5.12/5.12.9/single/qt-everywhere-src-5.12.9.tar.xz

下载后解压:

xz -d qt-everywhere-src-5.12.9.tar.xz
tar -xf qt-everywhere-src-5.12.9.tar

解压后的目录大小2.8G,内容如下:

二、交叉编译qt源码

1. 修改qmake.conf

修改qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf文件。

#
# qmake configuration for building with arm-linux-gnueabi-g++
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC                = arm-linux-gnueabihf-gcc
QMAKE_CXX               = arm-linux-gnueabihf-g++
QMAKE_LINK              = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB        = arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR                = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY           = arm-linux-gnueabihf-objcopy
QMAKE_NM                = arm-linux-gnueabihf-nm -P
QMAKE_STRIP             = arm-linux-gnueabihf-strip
load(qt_config)

2. 配置编译选项

添加autoconfigure.sh脚本文件:

./configure -prefix /home/mculover666/develop/imx6ull/qt/qt-everywhere-src-5.12.9/arm-qt \
-opensource \
-confirm-license \
-release \
-strip \
-shared \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-c++std c++11 \
--rpath=no \
-pch \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdoc \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
-skip qtwebengine \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns \
-make libs \
-make examples \
-nomake tools -nomake tests \
-gui \
-widgets \
-dbus-runtime \
--glib=no \
--iconv=no \
--pcre=qt \
--zlib=qt \
-no-openssl \
--freetype=qt \
--harfbuzz=qt \
-no-opengl \
-linuxfb \
--xcb=no \
-tslib \
--libpng=qt \
--libjpeg=qt \
--sqlite=qt \
-plugin-sql-sqlite \
-I/home/mculover666/develop/imx6ull/tool/tslib-1.22-build/include \
-L/home/mculover666/develop/imx6ull/tool/tslib-1.22-build/lib \
-recheck-all

给脚本可执行权限:

sudo chmod +x autoconfigure.sh

执行脚本开始配置:

./autoconfigure.sh

3. 编译

make -j16

4. 安装

make install

安装完之后查看安装内容和大小:

将安装的文件夹打包备份:

tar -jcf armhf-qt-5.12.9.tar.bz2 arm-qt

三、移植qt到开发板rootfs

1. 拷贝qt安装文件

将上一节的压缩包armhf-qt-5.12.9.tar.bz2拷贝到跟文件下系统,解压:

tar xf armhf-qt-5.12.9.tar.bz2 -C /usr/lib

2. 配置Qt5的环境变量

export QT_ROOT=/usr/lib/arm-qt  
export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event1
export QT_QPA_FONTDIR=/usr/share/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
export QT_PLUGIN_PATH=$QT_ROOT/plugins
export LD_LIBRARY_PATH=$QT_ROOT/lib:$QT_ROOT/plugins/platforms
export QML2_IMPORT_PATH=$QT_ROOT/qml
export QT_QPA_FB_TSLIB=1  

额外配置tslib库的地址:

export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so

环境变量生效:

source /etc/profile

3. 测试

运行demo:

cd /usr/lib/arm-qt/examples/widgets/widgets/digitalclock
./digitalclock

效果如下:

四、搭建Qt Creator开发环境

1. 下载Qt Creator

下载地址:https://download.qt.io/archive/qt/5.12/5.12.9/

wget https://download.qt.io/archive/qt/5.12/5.12.9/qt-opensource-linux-x64-5.12.9.run

2. 安装Qt Creator

添加可执行权限:

sudo chmod +x qt-opensource-linux-x64-5.12.9.run

执行,就有了一个安装界面:

sudo ./qt-opensource-linux-x64-5.12.9.run



3. 配置Qt Creator

启动Qt Creator:

/opt/Qt5.12.9/Tools/QtCreator/bin/qtcreator.sh &


(1)配置qmake为之前交叉编译安装的:

(2)配置gcc编译器

(3)配置Kits

4. 新建工程



两个开发套件都选:

添加一个控件:

在电脑上运行的效果:

选择arm平台编译套件:

编译工程:

找到编译出的可执行文件:

拷贝到开发板上运行,效果如下:

开启调试日志,提示缺少字体,添加字体后,效果如下:

五、移植遇到的问题汇总

1. 缺少python命令

问题描述:make install的时候,安装qml提示缺少python。

问题分析:ubuntu20.04里有python 3.8,需要python3才行,没有默认的python命令,所以造一个软链接即可。

sudo ln -s /usr/bin/python3 /usr/bin/python

再次执行make install即可。

2. 运行demo后提示缺少libts.so库

问题描述:执行demo后没有任何反应。

问题定位:开启qt debug日志输出,进一步找出问题所在位置。

export QT_DEBUG_PLUGINS=1

开启之后看到出错位置,提示缺少libts.so.0库:

问题解决: 在环境变量里添加该库的配置。

export LD_PRELOAD=$TSLIB_ROOT/lib/libts.so

重新生效环境变量,再次执行demo,正常运行。

3. 缺少字体

在开发板rootfs上创建/usr/share/fonts目录,将字库拷贝进去:

创建 /etc/fonts/fonts.conf 文件,加入以下内容:


<!-- Font directory list -->

        <dir>/usr/share/fonts</dir>

        <dir prefix="xdg">fonts</dir>
        <!-- the following element will be removed in the future -->
        <dir>~/.fonts</dir>

参考资料

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mculover666

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值