|
本帖最后由 conway 于 2015-5-6 15:48 编辑
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、解压:
[mw_shl_code=applescript,true]$ tar xzf qt-everywhere-opensource-src-5.4.1.tar.gz
$ cd qt-everywhere-opensource-src-5.4.1/[/mw_shl_code]
4、指定所用平台的arm架构以及交叉编译器:
[mw_shl_code=applescript,true]$ vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf[/mw_shl_code]
改成以下内容,实际应需要根据自己的开发环境作出相应改变:
[mw_shl_code=applescript,true]#
# 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 += -O2 -march=armv7-a
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-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)[/mw_shl_code]
5、根据自己的实际需求配置Qt:
[mw_shl_code=applescript,true]$ ./configure \
-prefix /usr/local/qt5.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-sse2 \
-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[/mw_shl_code]
6、编译安装:
[mw_shl_code=applescript,true]$ make
$ sudo make install[/mw_shl_code]
7、移植Qt到开发板:
完成上述步骤后,qt5.4.1将被安装到/usr/local/qt5.4.1中。然后将/usr/local/中的qt5.4.1复制到开发板的/opt/目录中,将/usr/local/中的tslib复制到开发板的/usr/local/中。
8、设置开发板Qt环境变量:
[mw_shl_code=applescript,true]root@MYD-AM335X:~# vi /etc/init.d/qt.sh[/mw_shl_code]
添加下面内容:
[mw_shl_code=applescript,true]export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
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/qt5.4.1/lib
export PATH=/bin:/sbin:/usr/bin/:/usr/sbin:/usr/local/tslib/bin
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/qt5.4.1/plugins
export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
export QT_QPA_FONTDIR=/opt/qt5.4.1/lib/fonts
export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE[/mw_shl_code]
保存退出后使上面的环境变量生效:
[mw_shl_code=applescript,true]root@MYD-AM335X:~# source /etc/init.d/qt.sh[/mw_shl_code]
9、运行一些example:
[mw_shl_code=applescript,true]root@MYD-AM335x ~# /opt/qt5.4.1/examples/touch/pinchzoom/pinchzoom[/mw_shl_code]
[mw_shl_code=applescript,true]root@MYD-AM335x ~# /opt/qt5.4.1/examples/svg/embedded/fluidlauncher/fluidlauncher[/mw_shl_code]
我们可以看到用linuxfb方式的运行的QT是没有窗体边框的,这是qt5的一个特点,似乎是其为了更好的转移到手机等移动终端。
|
|