Friday, December 11, 2009

Qt Application development on mini2440

Introduction

This blog emphasize on building QT based GUI application for embedded linux , Its describes on setting up the IDE for QT ,cross compiling QT 4.5 libraries for embedded application on mini2440 board in particular.


Setting QT Creator (IDE).

Qt Creator is a new cross-platform integrated development environment (IDE) tailored to the needs of Qt developers, Qt SDK includes the tools you need to build cross-platform applications with Qt in a single install.

Qt libraries

Qt Creator IDE

Qt development tools


Use the below link to download Qt SDK.

http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2009.05.bin

Login as root to the host machine and run the the binary file on the command promt.

LinuxHost>chmod +x qt-sdk-linux-x86-opensource-2009.05.bin

LinuxHost>./qt-sdk-linux-x86-opensource-2009.05.bin

Now once the installation is complete,run the QT Creator by clicking on desktop icon.


Navigate Tools->Options

Select the Qt installation path, in my case it is PATH “/opt/qtsdk-2009/qt”.

Now click on rebuild button to configure it,on success Qt creator will check the 'Debugging Helper'

The IDE is set to develop QT application for the Host machine.



Cross compilation of QT 4.5.3 for mini2440 board.

  1. Download the compressed package

http://qt.nokia.com/downloads/embedded-linux-cpp

now extract qt-embedded-linux-opensource-src-4.5.3.tar.gz to an appropriate folder and configure the source,it is assumed that the cross compiler is installed and the path is updated in the environment variable.



\path-to-mini2440\>tar -zxvf qt-embedded-linux-opensource-src-4.5.3.tar.gz

\path-to-mini2440>cd qt-embedded-linux-opensource-src-4.5.3

\path-to-mini2440\qt-embedded-linux-opensource-src-4.5.3>:



2. Compile the qt-embedded-linux-opensource-src-4.5.3. Remove some unnecessary features, keep most of the commonly used functions, and add support for the tslib touch screen recalibration.

./configure \
-prefix /new_disk/Hiteg/qt/build/ //specify the directory for installation,
-release -shared \
-fast \
-pch \
-no-qt3support \
-qt-sql-sqlite \
-no-libtiff -no-libmng \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-no-openssl \
-nomake examples -nomake demos -nomake tools \
-optimized-qmake \
-no-phonon \
-no-nis \
-no-opengl \
-no-cups \
-no-xcursor -no-xfixes -no-xrandr -no-xrender -no-xkb -no-sm \
-no-xinerama -no-xshape \
-no-separate-debug-info \
-xplatform qws/linux-arm-g++ \
-embedded arm \
-depths 16 \
-no-qvfb \
-qt-gfx-linuxfb \
-no-gfx-qvfb -no-kbd-qvfb -no-mouse-qvfb\
-qt-kbd-usb \
-confirm-license \
-qt-mouse-tslib

$ make (or gmake)
$ make install (or gmake install)
3.Build filesystem, copy necessary Qt libraries to the filesystem directory:
cd $rootfs #$rootfs is the filesystem directory

mkdir new_disk/hiteg/qt/build –p && cd new_disk/hiteg/qt/build
cp /new_disk/hiteg/qt/build/lib/libQtCore.so ./
cp /new_disk/hiteg/qt/build/lib/libQtGui.so.4 ./
cp /new_disk/hiteg/qt/build/lib/libQtNetwork.so.4 ./
mkdir fonts

copy the fonts that you want to implement in your Qt:

cp /mnt/qt/build/lib/fonts/xxxxx.qpf fonts


Installing tslib library on mini2440


  1. Where to download tslib source code.
    addr1 http://www.zelow.no/floppyfw/download/Development/src/(I suggest use this one)
    addr 2 http://mail.pdaxrom.org/download/1.1.0beta3/src/

2. How to compile
We've to manual set some enviroment virables. and correctly configure the source code. I show you a build file wrote myself:
#step 1 play a trick
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.autogen

#step 2 set the enviroment
export CC=/cross-compile/bin/arm-linux-gcc
export CXX=/cross-compile/bin/arm-linux-g++
export CONFIG_SITE=arm-linux.autogen
#step 2
./configure --build=i386-linux --host=arm-linux --target=arm --disable-inputapi --prefix=/new_disk/Hiteg/qt//build

do make and make install,you will get what you want under ./build. Actually you can set the prefix as your root_fs befor hand then after the "make install" these file are stay on position.


3. Copy the libraries to the standard library path in file system and make it available to the application.

3.1 initialize the environment setting first, you'd better place them in /etc/profile or other place you like.
QTDIR=/new_disk/Hiteg/qt-arm/build
LD_LIBRARY_PATH=$QTDIR/lib
TSLIB_CONSOLEDEVICE=none
TSLIB_FBDEVICE=/dev/fb0
TSLIB_TSDEVICE=/dev/input/event0
TSLIB_CALIBFILE=/etc/pointercal
TSLIB_CONFFILE=/usr/local/etc/ts.conf
QWS_SIZE=240x320
QWS_DISPLAY="LinuxFb:mmWidth135:mmHeight155"
QWS_MOUSE_PROTO="Tslib:/dev/input/event0"
TSLIB_PLUGINDIR=$QTDIR/lib/ts
export USER LOGNAME PS1 PATH
export QTDIR
export LD_LIBRARY_PATH
export TSLIB_CONSOLEDEVICE
export TSLIB_FBDEVICE
export TSLIB_TSDEVICE
export TSLIB_CALIBFILE
export TSLIB_CONFFILE
export QWS_SIZE
export QWS_DISPLAY
export QWS_MOUSE_PROTO
export TSLIB_PLUGINDIR