主机:Ubuntu12.04
目标板:AtmelAT91SAM9X5-EK开发板
交叉编译器:4.4.1
Qtopia4.4.3的移植包括两个软件包的移植,在移植Qtopia4.4.3时,得先移植tslib,因为在编译和运行Qt时需要用到tslib库。这个库是用做屏幕校准的。
一、tslib编译移植
编译tslib需要autoconf、automake、libtool包支持,在编译之前先在主机上安装这些包。
#apt-get install autoconf
#apt-get install automake
#apt-get install libtool
1、解压源码
#tar xzvf tslib.tar.gz
2、把auto.sh脚本复制到tslib的根目录下
3、进入到tslib目录,运行auto.sh脚本
auto.sh脚本:
#!/bin/sh
export PATH=/usr/local/arm/4.4.1/bin:$PATH
export TOOLCHAIN=/usr/local/arm/4.4.1
export TB_CC_PREFIX=arm-linux-
export PKG_CONFIG_PREFIX=$TOOLCHAIN/arm-none-linux-gnueabi
./autogen.sh
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache
./configure \
--host=arm-linux \
--cache-file=arm-linux.cache \
--enable-inputapi=no \
PLUGIN_DIR=/usr/local/arm/tslib/plugins \
-prefix=/usr/local/arm/tslib \
-host=arm-linux \
--cache-file=arm-linux.cache \
2>&1 | tee conf_log
make 2>&1 | tee make_log
make install
#./auto.sh
编译、安装完成之后,就可以在/usr/local/arm/的目录下看到tslib目录,修改tslib目录下etc/tslib.conf的配置文件,把第二行:# module_raw input的注释符号“#”和前面的空格去掉。修改完成之后就可以把tslib整个文件复制到目标板上的/usr/local/arm/的目录下了。
二、编译安装Qtopia4.4.3
编译Qtopia4.4.3也需要libx11-dev、libxext-dev、libxtst-dev包的支持。在编译之前先安装这些包。
#apt-get install libx11-dev
#apt-get install libxext-dev
#apt-get install libxtst-dev
如果主机上没有安装g++,也得安装:
#apt-get install g++。
在编译Qt4.4.3时,交叉编译器的版本不要选得太高,之前我4.6.3的编译不通过,说编译器不支持Qt的一些语法,还有编译器的库最好是glib,我用过uClib库的编译器,编译也不通过,说缺少什么头文件。
将qt-extended-opensource-src-4.4.3.tar.gz源代码包和build编译脚本放到/opt/Qtopia4.4.3/文件夹下,运行编译脚本build
#./build
build脚本:
#!/bin/bash
rm qt-extended-4.4.3 -fr
tar xvzfqt-extended-opensource-src-4.4.3.tar.gz
rm -fr builddir
mkdir builddir
export PATH=/usr/local/arm/4.4.1/bin:$PATH
export TOOLCHAIN=/usr/local/arm/4.4.1
export TB_CC_PREFIX=arm-linux-
export PKG_CONFIG_PREFIX=$TOOLCHAIN/arm-none-linux-gnueabi
QTOPIA_PREFIX_DIR=/opt/Qtopia4.4.3
exportQTOPIA_DEPOT_PATH=$PWD/qt-extended-4.4.3
export QPEDIR=$PWD/builddir
export LC_CTYPE="en_US"
export LANG="en_US"
export LANGUAGE="en_US"
cd $QPEDIR
echo yes | $QTOPIA_DEPOT_PATH/configure \
-ui-type mobile \
-xplatform linux-arm-g++ \
-arch arm \
-release \
-clean \
-prefix ${QTOPIA_PREFIX_DIR} \
-sound-system oss \
-build-qt \
-no-sxe \
-no-ssl \
-no-v4l2 \
-no-vpn \
-no-phonon \
-no-libamr \
-dynamic-rotation \
-mediaengines cruxus \
-remove-mediaengine gstreamer,helix \
-pictureflow \
-remove-module bluetooth,drm \
-no-dbus \
-no-dbusipc \
-add-displaysize 480x272 \
-extra-qt-embedded-config "-embeddedarm -xplatform qws/linux-arm-g++ -no-cups -nomake examples -nomake demos-qt-zlib -qt-libjpeg -qt-libmng -qt-libpng -no-dbus -depths 16,32-qt-gfx-linuxfb -qt-gfx-transformed -no-gfx-qvfb -no-gfx-vnc-no-gfx-multiscreen -qt-kbd-tty -no-kbd-usb -no-kbd-sl5000 -no-kbd-yopy-no-kbd-vr41xx -no-kbd-qvfb -qt-mouse-tslib -I/usr/local/arm/tslib/include -L/usr/local/arm/tslib/lib -no-webkit-no-openssl -no-phonon -no-phonon-backend -no-nas-sound -no-exceptions-svg" \
-extra-qt-config "-no-webkit" \
2>&1 | tee ../qtopiaconfig.log
bin/qbuild 2>&1 | tee../qtopia4.4.3makelog
bin/qbuild image
这个过程大概需要3到4个小时。编译完成后在/opt/Qtopia4.4.3/文件夹生成builddir目录,该目录下的image就是我们期待已久的Qtopia应用程序。把整个文件夹放到目标上的/opt/目录下并改名为Qtopia4.4.3、sdk目录是在主机上开发Qt的开发工具。
将qtopia4这个运行脚本放到:/usr/bin/目录下。qtopia4脚本代码如下:
#!/bin/sh
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_ROOT=/usr/local/arm/tslib
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CALIBFILE=/etc/pointercal
export QTDIR=/opt/Qtopia4.4.3
export QPEDIR=/opt/Qtopia4.4.3
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$TSLIB_ROOT/lib:$LD_LIBRARY_PATH
if [ -c ${TSLIB_TSDEVICE} ]; then
export QWS_MOUSE_PROTO="Tslib:${TSLIB_TSDEVICE}"
if [ -e /etc/pointercal -a ! -s /etc/pointercal ] ; then
rm /etc/pointercal
/usr/local/arm/tslib/bin/ts_calibrate
fi
else
export QWS_MOUSE_PROTO="USB:/dev/input/mice"
>/etc/pointercal
fi
export QWS_KEYBOARD="TTY:/dev/tty1"
#export QWS_DISPLAY="Transformed:mmWidth66:mmHeight114:Rot90:0"
FB_SIZE=$(cat /sys/class/graphics/fb0/virtual_size)
case "$FB_SIZE" in
800,480)
export QWS_DISPLAY="LinuxFb:mmWidth91:mmHeight53:1"
;;
480,272)
export QWS_DISPLAY="LinuxFb:mmWidth76:mmHeight44:1"
;;
*)
export QWS_DISPLAY="LinuxFb:mmWidth91:mmHeight53:1"
;;
esac
export LANG="en_US"
export HOME=/root/Qtopia4Home
if [ ! -e $HOME ]; then mkdir -p $HOME; fi
if [ ! -e /usr/share ]; then mkdir /usr/share; fi
if [ ! -e /usr/share/zoneinfo ]; then ln -s /opt/Qtopia4.4.3/etc/zoneinfo /usr/share/; fi
if [ ! -e $HOME/Settings/Trolltech/qpe.conf ]; then
mkdir -p $HOME/Settings/Trolltech/
cp $QPEDIR/etc/default/Trolltech/qpe.conf $HOME/Settings/Trolltech/qpe.conf -f
fi
export QTOPIA_PHONE_DUMMY=1
exec $QPEDIR/bin/qpe 1>/dev/null 2>/dev/null
修改/etc/init.d/rcS脚本,加上开机启动Qtopia。
/usr/bin/qtopia4&