实验室所用的AIO-3399ProC开发板,做项目需要用到Qt软件设计GUI界面和Qt的多线程并行化功能,故在开发板端和PC端部署Qt5.12.2交叉编译环境。本文记录了部署Firefly官方发布的Qt交叉编译工具链时的过程、遇到的问题及解决方案,以供本人和各位参考。
Qt 是一个1991年由Qt Company开发的跨平台C++图形用户界面应用程序开发框架。它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器。Qt是面向对象的框架,使用特殊的代码生成扩展(称为元对象编译器(Meta Object Compiler, moc))以及一些宏,Qt很容易扩展,并且允许真正地组件编程。
优良的跨平台特性:
Qt支持下述平台:
MS/Windows - 95、98、NT4.0、ME、2000、XP 、 Vista、Win7、win8、win2008、win10
Unix/X11 -Linux、SunSolaris、HP-UX、CompaqTru64 UNIX、IBMAIX、SGI IRIX、FreeBSD、BSD/OS和其它很多X11平台
Macintosh -Mac OS X
Embedded - 有帧缓冲(framebuffer)支持的嵌入式Linux平台,Windows CE、Symbian、Symbian^3、Symbian Anna、Symbian Belle、MeeGo、haiku-os。
面向对象:
Qt 的良好封装机制使得 Qt 的模块化程度非常高,可重用性较好,对于用户开发来说是非常方便的。 Qt 提供了一种称为 signals/slots 的安全类型来替代 callback,这使得各个元件之间的协同工作变得十分简单。
丰富的 API:
Qt 包括多达 250 个以上的 C++ 类,还提供基于模板的 collections, serialization, file, I/O device, directory management, date/time 类。甚至还包括正则表达式的处理功能。
支持 2D/3D 图形渲染,支持 OpenGL
大量的开发文档
支持XML。
注:本节内容引用自Qt百度百科
开发环境 | 软件版本/配置 |
---|---|
开发板型号 | Firefly AIO-3399 ProC开发板 (3+16GB) |
开发板操作系统 | Ubuntu 18.04LTS |
开发板固件版本 | AIO-RK3399PROC-UBUNTU18.04-GPT-20200525-1016.img |
PC系统版本 | Ubuntu 18.04LTS |
Qt版本 | 5.12.2 |
Qt Creator版本 | 4.8.2 |
Qt交叉编译工具包 | firefly_arm64_qt5.12.2_18.04_20210226.tgz |
电脑远程软件 | Xshell 6&Xftpd 6 |
Firefly发布的Qt交叉编译工具链,适用于以下环境:
Host(PC端): x86-64 / Ubuntu 18.04
Target(开发板端): Firefly RK3399Pro / RK3399 / RK3328 PX30 / Ubuntu 18.04 Minimal&Desktop
工具链完整支持wenEngine, 支持EGLFS LinuxFB XCB 等backend。
下载地址:https://pan.baidu.com/s/1tNGqG4XSYuDxe_AdDegOAA
提取码:FFQT
Qt Creator集成开发环境包在此链接下载qt-opensource-linux-x64-5.12.2.run这个文件,如下图红框所示处:
sudo apt install -y crossbuild-essential-arm64
安装交叉编译工具时,由于找不到aarch64-linux-gnu-gcc 和aarch64-linux-gnu-g++文件的路径,导致无法在Qt Creator中进行环境配置,所以不使用该方法安装交叉编译工具。)首先将下载好的firefly_arm64_qt5.12.2_18.04_20210226.tgz包通过XFtpd软件或者U盘复制到开发板的任意路径(本文将文件复制到了/home/firefly/路径)下。在命令行中执行以下操作:
#解压.tar文件
sudo tar zxvf firefly_arm64_qt5.12.2_18.04_20210226.tgz
cd ./firefly_arm64_qt5.12.2_18.04_20210226
#复制文件夹及其下所有文件到指定路径
sudo cp -rfd host/opt/firefly_qt5.12.2_arm64_18.04/ext /opt/firefly_qt5.12.2
#配置qt的环境变量
sudo cp target/qtEnv.sh /etc/profile.d/
#添加qt动态库加载路径
sudo cp target/qt.conf /etc/ld.so.conf.d
#重启开发板使其生效
sudo reboot
等待开发板系统重启后,执行以下操作:
#安装基础依赖环境
sudo apt install -y libgles2
sudo apt install -y libmtdev1 libinput10 libxkbcommon0 libdouble-conversion1 libicu60 libharfbuzz0b
#桌面环境选择xcb显示驱动 (Ubuntu Desktop)
sudo apt install -y \
libxcb-icccm4 \
libxcb-image0 \
libxcb-shm0 \
libxcb-keysyms1 \
libxcb-render0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-sync1 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb-xkb1 \
libxcb-randr0 \
libsm6 \
libice6 \
libxkbcommon-x11-0
export QT_QPA_PLATFORM=xcb
#重启使环境变量生效
source ~/.bashrc
sudo reboot
至此开发板端Qt交叉编译环境搭建完成。
将3.1节中下载好的gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz包复制到PC端Ubuntu系统的任意路径,执行下列命令安装交叉编译工具:
#将交叉编译工具包解压到/opt/文件夹下
tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz /opt/
#将交叉编译工具文件路径添加至环境变量
sudo vim /etc/profile
#在该文件末添加以下内容,esc后输入:wq退出即可
...
export PATH="/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:$PATH"
...
#重启使环境变量生效
source etc/profile
sudo reboot
安装完成后执行以下命令验证是否安装成功
user@admin-machine:~$ aarch64-linux-gnu-gcc -v
使用内建 specs。
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.5.0/lto-wrapper
目标:aarch64-linux-gnu
配置为:'/home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.5-2019.12/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --with-system-zlib --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu
线程模型:posix
gcc 版本 7.5.0 (Linaro GCC 7.5-2019.12)
user@admin-machine:~$ aarch64-linux-gnu-g++ -v
使用内建 specs。
COLLECT_GCC=aarch64-linux-gnu-g++
COLLECT_LTO_WRAPPER=/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.5.0/lto-wrapper
目标:aarch64-linux-gnu
配置为:'/home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.5-2019.12/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --with-system-zlib --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu
线程模型:posix
gcc 版本 7.5.0 (Linaro GCC 7.5-2019.12)
若打印出上列信息,表示交叉编译工具安装成功。
将3.1节中下载好的firefly_arm64_qt5.12.2_18.04_20210226.tgz包复制到PC端任意路径下,在命令行中执行以下操作:
#解压.taz文件
sudo tar zxvf firefly_arm64_qt5.12.2_18.04_20210226.tgz
cd ./firefly_arm64_qt5.12.2_18.04_20210226
sudo cp -rfd host/opt/* /opt/
#重启使环境变量生效
sudo cp host/qtEnv.sh /etc/profile.d/
sudo reboot
待PC端重启成功后,进入/firefly_arm64_qt5.12.2_18.04/example路径下,
执行以下命令测试是否可成功编译
user@admin-machine:~/firefly_arm64_qt5.12.2_18.04/example/openglwindow$ qmake
Info: creating stash file /home/user/firefly_arm64_qt5.12.2_18.04_20200721/firefly_arm64_qt5.12.2_18.04/example/openglwindow/.qmake.stash
user@admin-machine:~/firefly_arm64_qt5.12.2_18.04/example/openglwindow$ make
aarch64-linux-gnu-g++ -c -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -o openglwindow.o openglwindow.cpp
aarch64-linux-gnu-g++ -c -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -o main.o main.cpp
aarch64-linux-gnu-g++ -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -O2 -Wall -W -dM -E -o moc_predefs.h /opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/features/data/dummy.cpp
/opt/firefly_qt5.12.2_arm64_18.04/host/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB --include /home/user/firefly_arm64_qt5.12.2_18.04_20200721/firefly_arm64_qt5.12.2_18.04/example/openglwindow/moc_predefs.h -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -I/home/user/firefly_arm64_qt5.12.2_18.04_20200721/firefly_arm64_qt5.12.2_18.04/example/openglwindow -I/home/user/firefly_arm64_qt5.12.2_18.04_20200721/firefly_arm64_qt5.12.2_18.04/example/openglwindow -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include/c++/7.5.0 -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include/c++/7.5.0/aarch64-linux-gnu -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include/c++/7.5.0/backward -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.5.0/include -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.5.0/include-fixed -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include -I/opt/sysroot/firefly-arm64-sysroot-18.04/usr/local/include -I/opt/sysroot/firefly-arm64-sysroot-18.04/usr/include/aarch64-linux-gnu -I/opt/sysroot/firefly-arm64-sysroot-18.04/usr/include openglwindow.h -o moc_openglwindow.cpp
aarch64-linux-gnu-g++ -c -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -o moc_openglwindow.o moc_openglwindow.cpp
aarch64-linux-gnu-g++ --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -Wl,-O1 -Wl,-rpath-link,/opt/sysroot/firefly-arm64-sysroot-18.04/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/opt/sysroot/firefly-arm64-sysroot-18.04/lib/aarch64-linux-gnu -o openglwindow openglwindow.o main.o moc_openglwindow.o -L/opt/firefly_qt5.12.2_arm64_18.04/ext/lib -lQt5Gui -lQt5Core /opt/sysroot/firefly-arm64-sysroot-18.04/usr/lib/aarch64-linux-gnu/libGLESv2.so -lpthread
ls ./openglwindow
main.cpp main.o Makefile moc_openglwindow.cpp moc_openglwindow.o moc_predefs.h openglwindow openglwindow.cpp openglwindow.h openglwindow.o openglwindow.pri openglwindow.pro
可知/example/对应路径下生成可在开发板上执行的文件,将文件通过Xftpd或U盘复制到开发板任意路径下,执行./例子名称 文件,即可出现图形界面,如下图所示:
由此可在PC端的Qt交叉编译库可以正常使用。
#更改文件的访问权限
sudo chmod u+x qt-opensource-linux-x64-5.12.2.run
#运行文件进行Qt Creator的安装
./qt-opensource-linux-x64-5.12.2.run
在出现的图形界面中登录Qt账号后点下一步,
没有Qt账号的可以注册一下或者断网后跳过登录这步。
安装到默认路径,在选择组件时,只勾选安装Developer and Designer Tools即可,然后执行下一步等待安装完成。
#进入Qt Creator安装路径
cd /opt/Qt5.12.2/Tools/QtCreator/bin
sudo ./qtcreator.sh
点击Qt Creator菜单栏中的工具→选项
在Kits中的QtVersion中手动设置添加Qt的qmake所在路径,如下图红框处:
点击Apply应用生效。
在编译器选项添加交叉编译工具的aarch64-linux-gnu-gcc和aarch64-linux-gnu-g++文件路径,如下图红框处所示:
本文gcc和g++文件所在路径分别为:/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
在构建套件选项的手动设置中添加ARM,配置设备类型、编译器、Qt版本等参数,修改的地方如下图红框处所示:
点击OK按钮完成环境配置。
/opt/firefly_qt5.12.2_arm64_18.04/host/bin/uic ../test/mainwindow.ui -o ui_mainwindow.h
aarch64-linux-gnu-g++ -c -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../test -I. -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtWidgets -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I. -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -o main.o ../test/main.cpp
aarch64-linux-gnu-g++ -c -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../test -I. -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtWidgets -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I. -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -o mainwindow.o ../test/mainwindow.cpp
aarch64-linux-gnu-g++ -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -g -std=gnu++11 -Wall -W -dM -E -o moc_predefs.h /opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/features/data/dummy.cpp
/opt/firefly_qt5.12.2_arm64_18.04/host/bin/moc -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /home/user/build-test-ARM-Debug/moc_predefs.h -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -I/home/user/test -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtWidgets -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include/c++/7.5.0 -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include/c++/7.5.0/aarch64-linux-gnu -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include/c++/7.5.0/backward -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.5.0/include -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.5.0/include-fixed -I/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/include -I/opt/sysroot/firefly-arm64-sysroot-18.04/usr/local/include -I/opt/sysroot/firefly-arm64-sysroot-18.04/usr/include/aarch64-linux-gnu -I/opt/sysroot/firefly-arm64-sysroot-18.04/usr/include ../test/mainwindow.h -o moc_mainwindow.cpp
aarch64-linux-gnu-g++ -c -pipe -march=armv8-a -mtune=cortex-a72.cortex-a53 --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../test -I. -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtWidgets -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtGui -I/opt/firefly_qt5.12.2_arm64_18.04/ext/include/QtCore -I. -I. -I/opt/firefly_qt5.12.2_arm64_18.04/host/mkspecs/devices/linux-firefly-rk3399-g++ -o moc_mainwindow.o moc_mainwindow.cpp
aarch64-linux-gnu-g++ --sysroot=/opt/sysroot/firefly-arm64-sysroot-18.04 -Wl,-rpath-link,/opt/sysroot/firefly-arm64-sysroot-18.04/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/opt/sysroot/firefly-arm64-sysroot-18.04/lib/aarch64-linux-gnu -o test main.o mainwindow.o moc_mainwindow.o -L/opt/firefly_qt5.12.2_arm64_18.04/ext/lib -lQt5Widgets -lQt5Gui -lQt5Core /opt/sysroot/firefly-arm64-sysroot-18.04/usr/lib/aarch64-linux-gnu/libGLESv2.so -lpthread
17:31:35: 进程"/usr/bin/make"正常退出。
17:31:35: Elapsed time: 00:02.
如果编译成功,项目所在文件夹下会生成可执行文件,修改该文件的访问权限sudo chmod 777 ./文件名称
,通过Xftpd软件或U盘复制到开发板任意路径下,经测试,执行后开发板上出现图形界面,则表示PC端编译的Qt程序可以在开发板上运行,如下图所示:
至此PC端的Qt 及Qt Creator交叉编译环境配置完成。
3.4 本文主要参考的文章
《RK3399 ARM QT开发环境搭建》
《Ubuntu18.04交叉编译OpenCV3.4.9和QT5.12.2至ARM64位平台firefly-RK3399(一)》
《Ubuntu18.04交叉编译OpenCV3.4.9和QT5.12.2至ARM64位平台firefly-RK3399(二)》
《Ubuntu18.04交叉编译OpenCV3.4.9和QT5.12.2至ARM64位平台firefly-RK3399 (三)》
《交叉编译 QT5.12.2》
《QT5.12.1 ARM开发环境搭建 并 移植到RK3399 ubuntu16.04系统运行【完整版》】
《Firefly Ubuntu 使用手册》
附上Firefly官方给出的Qt5.12.2_Release.md安装文件内容
# Qt 5.12.2 arm64 ubuntu18.04 Cross Compile
Firefly Qt5.12.2 ,Work Environment
* Host(x86 PC) : ubuntu 18.04 x86_64
* Target(RK3399, RK3328, PX30): ubuntu 18.04 arm64
## Host Deployment
$ apt install -y crossbuild-essential-arm64
$ cd firfly_arm64_qt5.12.2_18.04
$ mkdir -p /opt
$ cp -rfd host/opt/* /opt/
$ cp host/qtEnv.sh /etc/profile.d/
reboot
# Target Deployment
$ cd firfly_arm64_qt5.12.2_18.04
$ cp -rfd host/opt/firefly_qt5.12.2_arm64_18.04/ext /opt/firefly_qt5.12.2
$ cp target/qtEnv.sh /etc/profile.d/
$ cp target/qt.conf /etc/ld.so.conf.d
$ ldconfig
$ reboot
$ [ -e /usr/lib/aarch64-linux-gnu/libGLESv2.so.2.0.0 ] || apt install -y libgles2
# Install base library
$ apt install -y \
libmtdev1 \
libinput10 \
libxkbcommon0 \
libdouble-conversion1 \
libicu60 \
libharfbuzz0b
#Qt QPA Backends
# linuxfb
$ export QT_QPA_PLATFORM=LINUXFB
$ export QT_QPA_FB_DRM=1
$ demo/analogclock
#eglfs
$ export QT_QPA_PLATFORM=EGLFS
$ export QT_QPA_EGLFS_INTEGRATION=EGLFS_KMS #in minimal ubuntu, use eglfs_kms.
$ export QT_QPA_EGLFS_KMS_ATOMIC=1 #use drm atomic api or legacy api(two different)
$ export QT_QPA_EGLFS_HIDECURSOR=1 #hide cursor
$ demo/openglwindow
#xcb (Ubuntu Desktop)
$ apt install -y \
libxcb-icccm4 \
libxcb-image0 \
libxcb-shm0 \
libxcb-keysyms1 \
libxcb-render0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-sync1 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb-xkb1 \
libxcb-randr0 \
libsm6 \
libice6 \
libxkbcommon-x11-0
$ export QT_QPA_PLATFORM=xcb
## Cross Compile on Host
```shell
$ cd example/
$ qmake
$ make
本文总结了开发板和PC端部署Qt交叉编译环境的过程,尚未测试Qt与opencv-python结合,编译程序的方法。待测试后再更新此文。以上内容可能有遗漏或者错误的地方,欢迎各位指正。