转自Qt5.2.1交叉编译,带tslib插件
一: 源码下载地址:
1.1: 平台:
主机:ubuntu 14.04
开发板: cpu arm-cortex-a8,故而我在配置我的qmake.conf的时候填写的为armV7-a
QT版本: qt everywhere opensource 5.2.1
Busybox版本:busybox-1.22.0
arm交叉编译工具:arm-none-linux-gnueabi 4.8.1
1.2: 交叉编译工具:
版本: arm-none-linux-gnueabi 4.8.1
附上我用的交叉编译工具,我把他上传到csdn是为了备份.由于我的账号在csdn的限制为60M,故而我将文件分为了8份.由于写这篇文章的时候上传的资料智能看见第八份,故而这里只有这么一个链接.
http://download.csdn.net/detail/mkndg/7374909
1.3: Qt5.2.1下载地址:
http://download.qt-project.org/archive/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz
1.4: tslib1.4下载地址:
http://download.csdn.net/detail/MKNDG/3291565
二: 交叉编译
步骤如下:
1:安装交叉编译工具
1.1: 将下载的交叉编译工具解压(用sudo解压),得到一个arm-4.8.1的文件夹,将其移动到/usr/local下面去
1.2: 添加全局环境变量:
vim /etc/bash.bashrc,在此文件的最后写上这一句:
- export PATH=/usr/local/arm-4.8.1/bin:$PATH
2:交叉编译tslib1.4
2.1:解压tslib1.4并进入其中,编写配置文件
在此文件中写入以下内容并保存退出:
- #!/bin/sh
- make clean && make distclean
- echo "ac_cv_func_malloc_0_nonnull=yes" >arm-linux.cache
- CC=/usr/local/arm-4.8.1/bin/arm-linux-gcc ./configure --host=arm-linux --prefix=/usr/local/tslib1.4 --cache-file=arm-linux.cache
- make && make install
然后:
- chmod a+x configTslib14.sh && sudo ./configTslib14.sh
3:解压qteverywhere包:
- tar -xvf qt-everywhere-opensource-src-5.2.1.tar.gz && cd qt-everywhere-opensource-src-5.2.1
3.1:编写configure文件:
vim 或者
- gedit configInstallQt5.2.1.sh
根据需要在里面写入需要的configure内容,我的配置如下:
- ./configure -prefix /usr/local/qt-5.2.1-embedded-arm-linux -release -opensource -qt-libpng -qt-libjpeg -plugin-sql-sqlite -widgets -qt-sql-sqlite -make libs -no-cups -no-nis -no-iconv -no-dbus -no-openssl -no-iconv -no-accessibility -no-javascript-jit -no-sse2 -silent -xplatform linux-arm-gnueabi-g++ -nomake tools -nomake examples -nomake tests -qt-freetype -no-glib -strip -linuxfb -plugindir /usr/local/qt-5.2.1-embedded-arm-linux/plugins -I/usr/local/tslib1.4/include -L/usr/local/tslib1.4/lib -confirm-license "$@" -verbose
3.3:配置qmake.conf
- vim qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf
我的此文件配置如下:
- MAKEFILE_GENERATOR = UNIX
- CONFIG += incremental gdb_dwarf_index
- 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/tslib1.4/include
- QMAKE_LIBDIR += /usr/local/tslib1.4/lib
-
- QMAKE_CC = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-gcc -lts
- QMAKE_CXX = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-g++ -lts
- QMAKE_LINK = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-g++ -lts
- QMAKE_LINK_SHLIB = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-g++ -lts
-
- QMAKE_AR = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-ar cqs
- QMAKE_OBJCOPY = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-objcopy
- QMAKE_NM = /usr/local/arm-4.8.1/bin/arm-linux-gnueabi-nm -P
- QMAKE_STRIP = /usr/local/arm-4.8.1/bin/arm-none-linux-gnueabi-strip
-
- load(qt_config)
执行:
- chmod a+x configInstallQt5.2.1.sh && sudo ./configInstallQt5.2.1.sh && sudo make -j 8 && sudo make install -j 8
3.4:为qt添加tslib插件
- vim tslibPluginInstall.sh
- sudo cp qt-everywhere-opensource-src-5.2.1/qtbase/bin/qmake /usr/bin/qmake_emb_5.2.1
- cd qt-everywhere-opensource-src-5.2.1/qtbase/src/plugins/generic/tslib/
- sudo cp /usr/local/tslib1.4/include/tslib.h ./
- qmake_emb_5.2.1
- sudo make && sudo make install
- chmod a+x tslibPluginInstall.sh && sudo ./tslibPluginInstall.sh
三:将编译好的qt库以及tslib库移植到文件系统中并写好配置文件
根据需要将qt下面的库拷贝到文件系统,包括qt安装目录下面的plugins文件夹
- #!/bin/sh
- QTPATH=/usr/local/qt-5.2.1-embedded-arm-linux
- TSLIBPATH=/usr/local/tslib1.4
- NFSROOTPATH=~/nfsroot
- rm -rf $NFSROOTPATH$QTPATH/fonts
- cp ./fonts $NFSROOTPATH$QTPATH/ -arf
- sudo cp $QTPATH/lib/* $NFSROOTPATH$QTPATH/ -arf
- sudo cp $TSLIBPATH $NFSROOTPATH/ -arf
- rm -rf $NFSROOTPATH$QTPATH/*.la $NFSROOTPATH$QTPATH/*.prl
- sudo cp $QTPATH/plugins $NFSROOTPATH$QTPATH/ -arf
- chmod a+x qtAndTsInstall.sh && sudo ./qtAndTsInstall.sh
文件系统的profile文件如下:
- vim ~/nfsroot/etc/profile
- export QTDIR=/usr/local/qt-5.2.1-embedded-arm-linux
- export PATH=$QTDIR:$PATH
- export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
- export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
- export QT_QPA_FONTDIR=$QTDIR/fonts
- export TSLIB_ROOT=/usr/local/tslib1.4
- export TSLIB_CALIBFILE=/etc/pointercal
- export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
- export TSLIB_FBDEVICE=/dev/fb0
- export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
- export TSLIB_CONSOLEDEVICE=none
- export TSLIB_TSDEVICE=/dev/touchscreen
- export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
- export QWS_MOUSE_PROTO=tslib:$TSLIB_TSDEVICE
- export set QWS_DISPLAY=LinuxFb:/dev/fb0
- export set QWS_SIZE=640x480
- export set QT_QWS_FONTDIR=$QTDIR/fonts/
- export set LD_LIBRARY_PATH=$QTDIR:$QT_QPA_PLATFORM_PLUGIN_PATH:$QT_QPA_FONTDIR:$TSLIB_ROOT/lib:$TSLIB_PLUGINDIR:$LD_LIBRARY_PATH
这样整个文件系统的环境就搭好了.交叉编译的时候用qmake_emb_5.2.1就可以了.
运行的时候直接运行,例如: ./test