Monday, December 20, 2010

Building Qt 4.7.1 for Arm (QQ2440/Mini2440)

This post will tell you how to compile Qt for any ARM based processor, S3C2440 in my case.
You need to download the latest source code from Nokia website. Click here to download version 4.7.1. Ignore the below task if you already have download the source.
# wget
Untar the source to a local directory (example: /home/user/USER/)
# tar -xzvf qt-everywhere-opensource-src-4.7.1.tar.gz
Specify which cross-compiler to use by setting the PATH environment variable.
# export PATH=path/to/cross/compiler:$PATH
You have to modify the mkspecs/qws/linux-arm-g++/qmake.conf file for toolchain related paths that Qt will use for compilation. Modify the below entries according to your toolchain.
QMAKE_CC = arm-none-linux-gnueabi-gcc
QMAKE_CXX = arm-none-linux-gnueabi-g++
QMAKE_LINK = arm-none-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-none-linux-gnueabi-g++
QMAKE_AR = arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-none-linux-gnueabi-objcopy
QMAKE_RANLIB = arm-none-linux-gnueabi-ranlib

Now your code base is ready for compilation. Start the compilation by following command.
# cd qt-everywhere-opensource-src-4.7.1
# ./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/local/Qt \
-qt-mouse-tslib -little-endian -no-webkit -no-qt3support -no-cups -no-largefile \
-optimized-qmake -no-openssl -nomake tools
# make && make install

To run your ARM compiled applications we have to set following environment variables on the NFS root of the board.
# export TSLIB_FBDEVICE=/dev/fb0
# export TSLIB_TSDEVICE=/usr/input/ts
# export TSLIB_CALIBFILE=/usr/etc/pointercal
# export TSLIB_CONFFILE=/usr/etc/ts.conf
# export TSLIB_PLUGINDIR=/usr/lib/ts
# export LD_LIBRARY_PATH=/usr/local/Qt/lib
# export QTDIR=/usr/local/Qt
# export QWS_MOUSE_PROTO=tslib:/usr/input/ts
# export QWS_DISPLAY=LinuxFB:mmWidth=240:mmHeight=320

The Qt library binary (and fonts subdir) should be placed on a user defined directory of the board and then set LD_LIBRARY_PATH to this directory.
Qt binary application must be run with -qws command line argument to inform Qt that we are working on a Linux embedded system.


  1. Hi,
    Great tutorial, have you test a example program, because if i run a simple test program mini2440 say:
    Segmantation fault

  2. Try configuring QT with the option: "-no-freetype". It should work.

  3. Hi,
    Thanks for this tutorial. I need help with Touchscreen.
    I compiled Qt and tslib successfully.
    Typing "cat /dev/input/ts" works as mentioned (weird chars when touched).
    ts_calibrate and ts_test work fine too (touch screen is working fine).

    If I use "export QWS_MOUSE_PROTO=tslib:/dev/input/ts" it shows "Segmentation fault". When I replace this line by just "export QWS_MOUSE_PROTO=" (without :") my "Hello World" app shows perfectly, but no touch screen.

    Compiling Qt with "-no-freetype" generates the same result: "Segmentation fault".

    I can't find a way to work touch with my app.

    Any suggestion?
    Thank you.