Qt5.4.1移植到arm——Linuxfb篇
Qt5与Qt4对比有很大的改变,其最大的特性在于模块化,并且很明显的是不再见到Qt4用到的qws,Qt5新增了QPA系统,基于QPA使得Qt5移 植到一个新平台非常简单而又具有极强的底层扩展能力;同时,C++11 也获得全面支持,使用 C++11 新特性更为方便。下面讲述将Qt5.4.1移植到MYD-AM335X的步骤:
1、编译并安装tslib1.4。这部分按照“MYD-AM335X Linux 3.2.0 用户手册”第1.10.2章节的步骤即可,最终将安装到/usr/local/tslib中。
2、到https://download.qt.io/archive/qt/5.4/5.4.1/single/下载源码包qt-everywhere-opensource-src-5.4.1.tar.gz
3、解压:
1
2
|
$ tar xzf qt - everywhere - opensource - src -5.4 . 1. tar.gz $ cd qt - everywhere - opensource - src -5.4 . 1 / |
4、指定所用平台的arm架构以及交叉编译器:
1
|
$ vi qtbase / mkspecs / linux - arm - gnueabi - g + + / qmake.conf |
改成以下内容,实际应需要根据自己的开发环境作出相应改变:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# # 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_RELEASE + = - O 2 - march = armv 7 - a QMAKE_CXXFLAGS_RELEASE + = - O 2 - march = armv 7 - a include ( .. / common / linux.conf ) include ( .. / common / gcc - base - unix.conf ) include ( .. / common / g + + - unix.conf ) QMAKE_INCDIR + = / usr / local / tslib / include QMAKE_LIBDIR + = / usr / local / tslib / lib # modifications to g++.conf QMAKE_CC = arm - linux - gnueabihf - gcc - lts QMAKE_CXX = arm - linux - gnueabihf - g + + - lts QMAKE_LINK = arm - linux - gnueabihf - g + + - lts QMAKE_LINK_SHLIB = arm - linux - gnueabihf - g + + - lts # 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 ) |
5、根据自己的实际需求配置Qt:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
$ . / configure \ - prefix / usr / local / qt 5.4 . 1 \ - confirm - license \ - opensource \ - release \ - make libs \ - xplatform linux - arm - gnueabi - g + + \ - optimized - qmake \ - pch \ - qt - sql - sqlite \ - qt - libjpeg \ - qt - libpng \ - qt - zlib \ - tslib \ - no - opengl \ - no - sse 2 \ - no - openssl \ - no - nis \ - no - cups \ - no - glib \ - no - dbus \ - no - xcb \ - no - xcursor - no - xfixes - no - xrandr - no - xrender \ - no - separate - debug - info \ - make examples - nomake tools - nomake tests - no - iconv |
6、编译安装:
1
2
|
$ make $ sudo make install |
7、移植Qt到开发板:
完成上述步骤后,qt5.4.1将被安装到/usr/local/qt5.4.1中。然后将/usr/local/中的qt5.4.1复制到开发板的/opt/目录中,将/usr/local/中的tslib复制到开发板的/usr/local/中。
8、设置开发板Qt环境变量:
1
|
root@MYD - AM 335 X : ~ # vi /etc/init.d/qt.sh |
添加下面内容:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
|
export TSLIB_CONSOLEDEVICE = none export TSLIB_FBDEVICE = / dev / fb 0 export TSLIB_TSDEVICE = / dev / input / event 1 export TSLIB_CONFFILE = / usr / local / tslib / etc / ts.conf export TSLIB_PLUGINDIR = / usr / local / tslib / lib / ts export TSLIB_CALIBFILE = / etc / pointercal export LD_LIBRARY_PATH = / lib : / usr / lib : / usr / local / tslib / lib : / opt / qt 5.4 . 1 / lib export PATH = / bin : / sbin : / usr / bin / : / usr / sbin : / usr / local / tslib / bin export QT_QPA_PLATFORM_PLUGIN_PATH = / opt / qt 5.4 . 1 / plugins export QT_QPA_PLATFORM = linuxfb : tty = / dev / fb 0 export QT_QPA_FONTDIR = / opt / qt 5.4 . 1 / lib / fonts export QT_QPA_GENERIC_PLUGINS = tslib : $TSLIB_TSDEVICE |
保存退出后使上面的环境变量生效:
1
|
root@MYD - AM 335 X : ~ # source /etc/init.d/qt.sh |
9、运行一些example:
1
|
root@MYD - AM 335 x ~ # /opt/qt5.4.1/examples/touch/pinchzoom/pinchzoom |
1
|
root@MYD - AM 335 x ~ # /opt/qt5.4.1/examples/svg/embedded/fluidlauncher/fluidlauncher |
我们可以看到用linuxfb方式的运行的QT是没有窗体边框的,这是qt5的一个特点,似乎是其为了更好的转移到手机等移动终端。
./configure -prefix /opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/qt-5.2.1-embedded-arm-MuliTCS -xplatform linux-arm-fr
eescale-gnueabi-g++ -confirm-license -opensource -release -make libs -optimized-qmake -pch -qt-sql-sqlite -qt-libjpeg -qt-libpng -qt-zlib -tslib -no-sse
2 -no-openssl -no-nis -no-cups -no-glib -no-separate-debug-info -nomake examples -nomake tools -nomake tests -no-iconv -skip webkit -opengl es2 -verbos
e -no-xcb-xlib -qt-xcb -qpa xcb
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental gdb_dwarf_index xlib
QMAKE_INCREMENTAL_STYLE = sublib
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a -mfloat-abi=softfp -mfpu=neon
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = arm-fsl-linux-gnueabi-gcc
QMAKE_CXX = arm-fsl-linux-gnueabi-g++
QMAKE_LINK = arm-fsl-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-fsl-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = arm-fsl-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-fsl-linux-gnueabi-objcopy
QMAKE_NM = arm-fsl-linux-gnueabi-nm -P
QMAKE_STRIP = arm-fsl-linux-gnueabi-strip
load(qt_config)
#QMAKE_INCDIR += /opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/include
#QMAKE_INCDIR += /opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/libX11/include
#QMAKE_LIBDIR += /opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/lib
#QMAKE_LIBDIR += /opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/qt-5.2.1-embedded-arm-MuliTCS/lib
#QMAKE_LIBDIR += /opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/libX11/lib
#QMAKE_LIBS+=-lXau -lxcb -lX11 -lX11-xcb
#QMAKE_INCDIR_OPENGL_ES2=/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/include
#QMAKE_LIBDIR_OPENGL_ES2=/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/lib
#QMAKE_LIBS_OPENGL_ES2=-lglapi -lGLESv2 -lEGL