Firefly AIO-3399ProC开发板与PC端部署Qt5.12.2交叉编译环境


前言

实验室所用的AIO-3399ProC开发板,做项目需要用到Qt软件设计GUI界面和Qt的多线程并行化功能,故在开发板端和PC端部署Qt5.12.2交叉编译环境。本文记录了部署Firefly官方发布的Qt交叉编译工具链时的过程、遇到的问题及解决方案,以供本人和各位参考。


一、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

三、部署Qt5.12.2交叉编译环境

3.1 安装前的相关包下载及环境准备

  • Qt交叉编译工具环境准备

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这个文件,如下图红框所示处:
在这里插入图片描述

  • PC端交叉编译工具下载
    PC端需要手动安装交叉编译工具aarch64-linux-gnu-gcc,该工具是由 Linaro 公司基于GCC推出的的ARM交叉编译工具,可用于交叉编译ARMv8 64位目标中的裸机程序、u-boot、Linux kernel、filesystem和App应用程序。aarch64-linux-gnu-gcc交叉编译器必须安装在64位主机上,才能编译目标代码。不能使用传统的arm-linux-交叉编译工具链,那些编译出来的都是32bit。
    最新7.5.0版本的下载地址,在该页面下载gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz文件,如下图红框所示处:
    在这里插入图片描述
    也可在官网上下载以前的版本 下载地址
    (注:按照Firefly官方Qt5.12.2_Release.md文件中的提示方法:sudo apt install -y crossbuild-essential-arm64安装交叉编译工具时,由于找不到aarch64-linux-gnu-gcc 和aarch64-linux-gnu-g++文件的路径,导致无法在Qt Creator中进行环境配置,所以不使用该方法安装交叉编译工具。)

3.2 在开发板端部署Qt5.12.2交叉编译环境

首先将下载好的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.3 在PC端部署Qt5.12.2交叉编译环境

3.3.1 安装交叉编译工具

将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.3.2 配置Qt交叉编译环境

将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交叉编译库可以正常使用。

3.3.3 安装配置Qt Creator 4.8.6

  1. 安装Qt Creator
    将3.1 节下载好的qt-opensource-linux-x64-5.12.2.run文件复制到PC端的任意路径下,执行以下命令安装:
#更改文件的访问权限
sudo chmod u+x qt-opensource-linux-x64-5.12.2.run
#运行文件进行Qt Creator的安装
./qt-opensource-linux-x64-5.12.2.run

在出现的图形界面中登录Qt账号后点下一步,
qt-opensource-linux-x64-5.12.2.run
没有Qt账号的可以注册一下或者断网后跳过登录这步。
在这里插入图片描述
安装到默认路径,在选择组件时,只勾选安装Developer and Designer Tools即可,然后执行下一步等待安装完成。

  1. 运行Qt Creator
#进入Qt Creator安装路径
cd /opt/Qt5.12.2/Tools/QtCreator/bin
sudo ./qtcreator.sh

即可运行Qt Creator。
在这里插入图片描述

  1. 配置Qt Creator交叉编译环境

点击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按钮完成环境配置。

  1. 新建项目测试在Qt Creator中编译的文件能否在开发板上运行
    ctrl+N 新建项目,在点击下图红框处,新建 Qt Widgets Application,Choose后进入编辑页面。
    在这里插入图片描述
    在项目中的Forms文件夹下打开mainwindow.ui文件,进入设计页面。
    在这里插入图片描述
    拖动按钮,设计个简单的GUI界面在这里插入图片描述
    在软件下栏打开4.编译输出,在左下栏的Debug图标上点Debug,然后点锤子图标构建项目,需要点的地方如下图红框处所示:
    在这里插入图片描述
    编译输出窗口打印以下日志:
/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结合,编译程序的方法。待测试后再更新此文。以上内容可能有遗漏或者错误的地方,欢迎各位指正。

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-aarch64-gnu-g++ (arm64, CPU features: neon) Target compiler: gcc 6.3.1 Configuration: cross_compile use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus reduce_exports stl Build options: Mode ................................... release Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++14 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs Qt modules and options: Qt Concurrent .......................... yes Qt D-Bus ............................... yes Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Support enabled for: Using pkg-config ....................... yes udev ................................... no Using system zlib ...................... yes Qt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. yes ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no Qt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ yes Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... yes SCTP ................................... no Use system proxies ..................... yes Qt Gui: Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no Image formats: GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... yes PNG .................................. yes Using system libpng ................ no EGL .................................... no OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no OpenGL ES 3.2 ........................ no Vulkan ................................. no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon .............................. no X11 specific: XLib ................................. no EGL on X11 ........................... no QPA backends: DirectFB ............................... no EGLFS .................................. no LinuxFB ................................ yes VNC .................................... yes Mir client ............................. no Qt Sql: SQL item models ........................ yes Qt Widgets: GTK+ ................................... no Styles ................................. Fusion Windows Qt PrintSupport: CUPS ................................... no Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt Testlib: Tester for item models ................. yes Qt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yes Qt QML: QML network support .................... yes QML debugging and profiling support .... yes QML sequence object .................... yes QML list model ......................... yes QML XML http request ................... yes QML Locale ............................. yes QML delegate model ..................... yes Qt Quick: Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes TableView item ......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes Repeater item .......................... yes ShaderEffect item ...................... yes Sprite item ............................ yes Qt Scxml: ECMAScript data model for QtScxml ...... yes Qt Gamepad: SDL2 ................................... no Qt 3D: Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Use SSE2 instructions .................. no Use AVX2 instructions .................. no Aspects: Render aspect ........................ yes Input aspect ......................... yes Logic aspect ......................... yes Animation aspect ..................... yes Extras aspect ........................ yes Qt 3D Renderers: OpenGL Renderer ........................ yes Qt 3D GeometryLoaders: Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no Qt Bluetooth: BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no WinRT Bluetooth API (desktop & UWP) .... no Qt Sensors: sensorfw ............................... no Qt Quick Controls 2: Styles ................................. Default Fusion Imagine Material Universal Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... yes Qt Positioning: Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no Qt Location: Qt.labs.location experimental QML plugin . yes Geoservice plugins: OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. no Itemsoverlay ......................... yes QtXmlPatterns: XML schema support ..................... yes Qt Multimedia: ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Qt Tools: QDoc ................................... no Qt WebEngine: Embedded build ......................... yes Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. no Use System Ninja ....................... no Geolocation ............................ yes WebChannel support ..................... yes Use v8 snapshot ........................ yes Kerberos Authentication ................ no Building v8 snapshot supported ......... yes Use ALSA ............................... no Use PulseAudio ......................... no Optional system libraries used: re2 .................................. no icu .................................. no libwebp, libwebpmux and libwebpdemux . no opus ................................. no ffmpeg ............................... no libvpx ............................... no snappy ............................... no glib ................................. no zlib ................................. yes minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no x11 .................................. no Required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. no glibc ................................ yes Required system libraries for qpa-xcb: libdrm ............................... no xcomposite ........................... no xcursor .............................. no xi ................................... no xrandr ............................... no xtst ................................. no Note: Also available for Linux: linux-clang linux-icc
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值