目录
前言
海思Hi3559AV100平台性能强悍,支持H264、H265 编码,分辨率可达16K,帧率可达120fps,应用于安防、无人机、智能机器人、人工智能、教育、车载设备、会议等诸多行业。但海思官方SDK并没有提供GUI组件,用户开发图形界面应用十分不便。
Qt 是一个跨平台的C++应用程序开发框架。它提供给开发者建立图形用户界面所需的功能,广泛用于开发图形用户界面程序,也可用于开发非图形用户界面(比如命令行界面)程序。Qt是完全面向对象的,很容易扩展,并且允许真正地组件编程。如果将Qt移植到Hi3559A平台,将极大地方便用户开发图形应用程序。
本系列将以Qt5.9.9为例详细介绍移植Qt全过程,包括:
- 从零搭建海思交叉编译环境;
- 交叉编译Qt5.9.9;
- H3559AV100平台运行Qt程序;
- 如何使Qt支持QML(GPU/EGLFS);
- 如何支持多点触控。
本文是Hi3559AV100移植Qt系列的第二篇,主要介绍如何对tslib、Qt源码进行配置和编译,最终生成支持tslib单点触摸的Qt库。
【参考】
- 海思Hi3559av100移植Qt5.9.7https://blog.csdn.net/year12/article/details/96170989
- 海思3559A QT 5.12移植(带webengine 和 opengl es)https://blog.csdn.net/weixin_30273175/article/details/95689400
1 准备
Qt源码:https://download.qt.io/archive/qt/5.9/5.9.9/single/qt-everywhere-opensource-src-5.9.9.tar.xz
tslib源码:https://github.com/libts/tslib
2 编译tsllib
tslib是一个跨平台的库,它提供了对触摸屏设备的访问以及对其输入事件进行过滤校准的能力。tslib在电阻触摸屏中使用很多,现代的电容触摸屏相对较少。个人认为其原因是电容触摸屏自带IC芯片处理输出的事件已经经过处理,输出已是可信的事件,无需再二次处理。tslib本身是支持多点触控,但是很可惜Qt对tslib的适配只支持单点触控,本系列文章最后一篇会介绍如何支持多点触控,以及在实现多点触控过程中遇到的问题和解决方法。
话不多说,回归正题。
1. 解压源码:unzip tslib-1.22.zip
2. 安装编译工具
virtual-machine:~/work/tslib-1.22$ sudo apt-get install autoconf automake libtool
2. 配置与编译
virtual-machine:~/work/tslib-1.22$ ./autogen.sh
virtual-machine:~/work/tslib-1.22$ ./configure --prefix=/opt/tslib_hi3559av100 --host=arm-linux CC=/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gcc
virtual-machine:~/work/tslib-1.22$ make
virtual-machine:~/work/tslib-1.22$ sudo make install
install之后的结果:
opt/tslib_hi3559av100/
├── bin
│ ├── ts_calibrate
│ ├── ts_conf
│ ├── ts_finddev
│ ├── ts_harvest
│ ├── ts_print
│ ├── ts_print_mt
│ ├── ts_print_raw
│ ├── ts_test
│ ├── ts_test_mt
│ ├── ts_uinput
│ └── ts_verify
├── etc
│ └── ts.conf
├── include
│ └── tslib.h
├── lib
│ ├── libts.la
│ ├── libts.so -> libts.so.0.10.4
│ ├── libts.so.0 -> libts.so.0.10.4
│ ├── libts.so.0.10.4
│ ├── pkgconfig
│ │ └── tslib.pc
│ └── ts
│ ├── debounce.la
│ ├── debounce.so
│ ├── dejitter.la
│ ├── dejitter.so
│ ├── evthres.la
│ ├── evthres.so
│ ├── iir.la
│ ├── iir.so
│ ├── input.la
│ ├── input.so
│ ├── invert.la
│ ├── invert.so
│ ├── linear.la
│ ├── linear.so
│ ├── lowpass.la
│ ├── lowpass.so
│ ├── median.la
│ ├── median.so
│ ├── pthres.la
│ ├── pthres.so
│ ├── skip.la
│ ├── skip.so
│ ├── touchkit.la
│ ├── touchkit.so
│ ├── variance.la
│ ├── variance.so
│ ├── waveshare.la
│ └── waveshare.so
└── share
└── man
├── man1
│ ├── ts_calibrate.1
│ ├── ts_conf.1
│ ├── ts_finddev.1
│ ├── ts_harvest.1
│ ├── ts_print.1
│ ├── ts_print_mt.1
│ ├── ts_print_raw.1
│ ├── ts_test.1
│ ├── ts_test_mt.1
│ ├── ts_uinput.1
│ └── ts_verify.1
├── man3
│ ├── ts_close.3
│ ├── ts_close_restricted.3
│ ├── ts_conf_get.3
│ ├── ts_config.3
│ ├── ts_conf_set.3
│ ├── ts_error_fn.3
│ ├── ts_fd.3
│ ├── ts_get_eventpath.3
│ ├── ts_libversion.3
│ ├── tslib_version.3
│ ├── ts_open.3
│ ├── ts_open_restricted.3
│ ├── ts_print_ascii_logo.3
│ ├── ts_read.3
│ ├── ts_read_mt.3
│ ├── ts_read_raw.3
│ ├── ts_read_raw_mt.3
│ └── ts_setup.3
└── man5
└── ts.conf.5
3 编译Qt
1. 解压源码:tar xvf qt-everywhere-opensource-src-5.9.9.tar.xz
解压源码后,工作目录如下:
virtual-machine:~/work$ pwd
/home/xiaoli/work
virtual-machine:~/work$ ls
aarch64-himix100-linux qt-everywhere-opensource-src-5.9.9
aarch64-himix100-linux.tgz qt-everywhere-opensource-src-5.9.9.tar.xz
gcc-arm-none-eabi-4_9-2015q3 tslib-1.22
gcc-arm-none-eabi-4_9-2015q3.tgz tslib-1.22.zip
Hi3559AV100_SDK_V2.0.2.0
我的环境下Hi3559a的sdk安装路径为/home/xiaoli/work/Hi3559AV100_SDK_V2.0.2.0,这个路径后续需要使用
2. 修改qmake.conf
基于现有的linux-arm-gnueabi目标平台,新建一个himix平台配置cp -dr linux-arm-gnueabi-g++ linux-aarch64-himix100-g++
virtual-machine:~/work$ cd qt-everywhere-opensource-src-5.9.9/qtbase/mkspecs/
virtual-machine:~/work/qt-everywhere-opensource-src-5.9.9/qtbase/mkspecs$ cp -dr linux-arm-gnueabi-g++ linux-aarch64-himix100-g++
将linux-aarch64-himix100-g++下的qmake.conf改为:
【注意】
/home/xiaoli/work/Hi3559AV100_SDK_V2.0.2.0需要根据实际轻快改成海思SDK对应的安装目录
#
# qmake configuration for building with aarch64-himix100-linux-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)
DEFINES += EGL_FBDEV
# gpu 注意路径为Hi3559A的SDK目录
QMAKE_INCDIR_EGL += /home/xiaoli/work/Hi3559AV100_SDK_V2.0.2.0/mpp/component/gpu/release/include
QMAKE_LIBDIR_EGL += /home/xiaoli/work/Hi3559AV100_SDK_V2.0.2.0/mpp/component/gpu/release/lib
QMAKE_LIBS_EGL += -lmali
QMAKE_INCDIR_OPENGL_ES2 += /home/xiaoli/work/Hi3559AV100_SDK_V2.0.2.0/mpp/component/gpu/release/include
QMAKE_LIBDIR_OPENGL_ES2 += /home/xiaoli/work/Hi3559AV100_SDK_V2.0.2.0/mpp/component/gpu/release/lib
QMAKE_LIBS_OPENGL_ES2 += -lmali
EGLFS_DEVICE_INTEGRATION = eglfs_mali
# modifications to g++.conf
QMAKE_CC = aarch64-himix100-linux-gcc
QMAKE_CXX = aarch64-himix100-linux-g++
QMAKE_LINK = aarch64-himix100-linux-g++
QMAKE_LINK_SHLIB = aarch64-himix100-linux-g++
# modifications to linux.conf
QMAKE_AR = aarch64-himix100-linux-ar cqs
QMAKE_OBJCOPY = aarch64-himix100-linux-objcopy
QMAKE_NM = aarch64-himix100-linux-nm -P
QMAKE_STRIP = aarch64-himix100-linux-strip
load(qt_config)
3. 编译配置
virtual-machine:~/work/qt-everywhere-opensource-src-5.9.9$ pwd
/home/raigor/work/qt-everywhere-opensource-src-5.9.9
virtual-machine:~/work/qt-everywhere-opensource-src-5.9.9$ ./configure -prefix /opt/qt5.9.9_hi3559a -opensource -confirm-license -release \
> -strip -eglfs -linuxfb -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype \
> -no-rpath -no-pch -no-avx -no-openssl -no-cups -no-dbus -no-pkg-config \
> -no-glib -no-iconv -xplatform linux-aarch64-himix100-g++ -make libs -opengl es2 \
> -nomake examples -nomake tools -qt-sqlite -tslib -I/opt/tslib_hi3559av100/include \
> -L/opt/tslib_hi3559av100/lib
配置结果:
Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-aarch64-himix100-g++ (arm64, CPU features: neon)
Configuration: cross_compile compile_examples enable_new_dtags largefile neon shared release c++11 c++14 c++1z concurrent no-pkg-config reduce_exports stl
Build options:
Mode ................................... release
Optimize release build for size ........ no
Building shared libraries .............. yes
Using C++ standard ..................... C++1z
Using ccache ........................... no
Using gold linker ...................... no
Using new DTAGS ........................ yes
Using precompiled headers .............. no
Using LTCG ............................. no
Target compiler supports:
NEON ................................. yes
Build parts ............................ libs
Qt modules and options:
Qt Concurrent .......................... yes
Qt D-Bus ............................... no
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 ....................... no
QML debugging .......................... yes
udev ................................... no
Using system zlib ...................... no
Qt Core:
DoubleConversion ....................... yes
Using system DoubleConversion ........ no
GLib ................................... no
iconv .................................. no
ICU .................................... no
Logging backends:
journald ............................. no
syslog ............................... no
slog2 ................................ no
Using system PCRE2 ..................... no
Qt Network:
getaddrinfo() .......................... yes
getifaddrs() ........................... yes
IPv6 ifname ............................ yes
libproxy ............................... no
OpenSSL ................................ no
Qt directly linked to OpenSSL ........ no
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 ............... no
PNG .................................. yes
Using system libpng ................ no
EGL .................................... yes
OpenVG ................................. no
OpenGL:
Desktop OpenGL ....................... no
OpenGL ES 2.0 ........................ yes
OpenGL ES 3.0 ........................ yes
OpenGL ES 3.1 ........................ yes
Session Management ..................... yes
Features used by QPA backends:
evdev .................................. yes
libinput ............................... no
INTEGRITY HID .......................... no
mtdev .................................. no
tslib .................................. yes
xkbcommon-evdev ........................ no
QPA backends:
DirectFB ............................... no
EGLFS .................................. yes
EGLFS details:
EGLFS OpenWFD ........................ no
EGLFS i.Mx6 .......................... no
EGLFS i.Mx6 Wayland .................. no
EGLFS RCAR ........................... no
EGLFS EGLDevice ...................... no
EGLFS GBM ............................ no
EGLFS Mali ........................... no
EGLFS Raspberry Pi ................... no
EGL on X11 ........................... no
LinuxFB ................................ yes
VNC .................................... yes
Mir client ............................. no
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows
Qt PrintSupport:
CUPS ................................... no
Qt Sql:
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 SerialBus:
Socket CAN ............................. yes
Socket CAN FD .......................... yes
QtXmlPatterns:
XML schema support ..................... yes
Qt QML:
QML interpreter ........................ yes
QML network support .................... 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
Path support ........................... yes
PathView item .......................... yes
Positioner items ....................... yes
ShaderEffect item ...................... yes
Sprite item ............................ yes
Qt Gamepad:
SDL2 ................................... no
Qt 3D:
Assimp ................................. yes
System Assimp .......................... no
Output Qt3D Job traces ................. no
Output Qt3D GL traces .................. no
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
Qt Sensors:
sensorfw ............................... no
Qt Quick Controls 2:
Styles ................................. Default 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:
Geoservice plugins:
OpenStreetMap ........................ yes
HERE ................................. yes
Esri ................................. yes
Mapbox ............................... yes
MapboxGL ............................. yes
Itemsoverlay ......................... 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 WebEngine:
Embedded build ......................... yes
Pepper Plugins ......................... no
Printing and PDF ....................... no
Proprietary Codecs ..................... no
Spellchecker ........................... yes
WebRTC ................................. no
Using system ninja ..................... no
ALSA ................................... no
PulseAudio ............................. no
System libraries:
re2 .................................. no
ICU .................................. no
libwebp and libwebpdemux ............. no
Opus ................................. no
ffmpeg ............................... no
4. 编译安装
make -j4
sudo make install
【错误1】
sh: python: command not found
Project ERROR: Building QtQml requires Python.
make: *** [Makefile:335: module-qtdeclarative-make_first] Error 3
解决方法:
sudo apt-get install python
安装后的目录结构:
/opt/qt5.9.9_hi3559a/
├── bin
├── doc
├── include
├── lib
├── mkspecs
├── plugins
├── qml
└── translations
4 总结
以上就是Qt编译的过程,总体比较顺利。下一篇会介绍Qt应用如何在海思单板上运行。