Cross Compiled QT Embedded – Step by Step

Well after a few hard days of figuring out stuff I finally got a compiled version of QT Embedded for ARM. I haven’t loaded it onto the device yet as I need to mess about with partitioning the SD card to get a bigger partition. I bought a new SD card today to back up the current one which I’ll be doing later on. 29.99 Euro – what a rip off!
Anyways so the past few days were crazy, frustrating but I finally got there. I set up my whole environment in a virtual environment using VMWare. I installed Xubuntu giving 512MB ram to it, 12Gig hard drive (however I did run into space issues further down but I deleted stuff that was not necessary to make room).

So first of all I had to install a tool chain. I tried building my own one using binutils and gcc+glibc/newlib sources but it was impossible to even get to the stage of having a bootstrap gcc “c” compiler. There isn’t too much information on building a compiler with modern sources,  now most people just download binary cross compilers such as the ones on codesourcery: I downloaded this and successfully built a helloworld program but moving it onto my board and executing it resulted in an “Illegal Instruction” message which obviously meant the cross compiler is compiling for a slightly different processor architecture even it be ARM. This could be to do with Debian Etch compiled for OABI instead of EABI. As far as I know most modern compilers are using EABI (Embedded Application Binary Interface). This means specifies a different file format to that of Old ABI (OABI). The EP9302 processor supports both modes but it is possible the version of Debian has being compiled as OABI meaning EABI instructions be incompatible and that’s the reason I get an Illegal Instruction message. I did run the file command on the binary file and it reported correctly, being an ARM executable so it definitely cross compiled for ARM.

Anyways I moved onto the Windows cross compiler with Eclipse that came on the SD card and I could successfully compile but same problems, Illegal Instruction. There was however a hello example called helloworld-aobi so I attempted to compile this but ran into problems. It uses Cygwin to execute gcc in a linux environment but paths got mixed up and I didn’t want to spend anymore time on it since I will be compiling QT Embedded on Linux in VMWare.

The SD card came with a pre-compiled toolchain, crosstool-linux-gcc-3.3.4-glibc-2.3.2-0.28rc39.tar.bz2. So i moved this into Xubunto and tar xvjf <the bz2 filename> and moved the contents into /usr/local/opt/crosstool/arm-linux. The bin directory in this are the actual tools we require so this needs to be added to the PATH environment variable. Instead of entering it everytime I edited my bash init file .bashrc with VI (vi ~/.bashrc) and entered the line export PATH=$PATH:/usr/local/opt/crosstool/arm-linux/bin in the top of the file. Note you better off doing same for root’s one so type su and enter root password. Then edit /root/.bashrc and enter the line here too. Reason for this is I found when you run sudo you in root mode and the environment variables don’t reflect so compiler’s may not be locatable.

So I created simple hello world C and C++ programs in my home directory and compiled using arm-linux-gcc for C and arm-linux-g++ for the C++ file. arm-linux-gcc helloworld.c -o helloworldc.out and arm-linux-g++ helloworld.cpp -o helloworldcpp.out. Compilmation was successful so I moved my two binaries to the home directory of Linux on my device. This can be done by exiting “fastboot” mode using consoleo (using the JTAG board connected to the pins and hyperterminal 115200/N81. Type exit at the linux prompt and the device will boot from the SD card. Now we can ftp from VMware to with user pass eclipse/eclipse. So I placed the files in the home directory (root on FTP). Using telnet to I navigated to /home/eclipse and chmodded the two files to 755 to be able to execute. (chmod 755 <filename>). The owners of this file are now eclipse but telnet logs in as root (with no password) so there should be no problems. Executing the programs ($ ./helloworldc.out) I got my printf of hello world so everything is ok. Now for QT Embedded.

Setting up QT Embedded was a Pain. First of all I need to install QT in order to compile the virtual frame buffer device used to display the QT/Embedded programs on my host x86 (not target). I then compiled QT/E for my host. These steps were ok but it got a bit tricky when I needed to cross compile.

Here are the steps I took anyways, hope they work for someone out there as well. Some steps may be unnecessary such as tmake but do it in case – I came across somewhere about it so installed it just in case. I’m not pretending to be an expert here or anything but these steps may help anyways. If you have any problems, drop me an email or comment and I’ll try give a hand. It is quite a lonely procedure and finding documentation is tough so if problems encountered you must be able to troubleshoot them yourself.

(These stsps are done on Xubuntu in my virtual machine. Note the building steps can take many hours to complete. My username here is donal, obviously replace this with your own)

$cd ~
$ mkdir -p project/downloads/qt_embedded
$ mkdir -p project/sysapps/host
$ mkdir project/sysapps/device
$ cd ~/project/downloads/qt_embedded/
$ wget
$ wget

$ cd ~/project/sysapps/host
$ tar -xzvf
$ tar -xzvf ~/project/downloads/qt_embedded/qt-x11-opensource-src-4.4.3.tar.gz
$ export QT4DIR=~/project/sysapps/host/qt_embedded/qt-x11-opensource-src-4.4.3/
$ export QTEDIR=~/project/sysapps/host/

// Few requirements
$ sudo apt-get install libx11-dev libxmu-dev libpng12-dev
$ sudo apt-get install libxtst-dev
$ sudo apt-get install build-essential

$ cd $QT4DIR
$ export QTDIR=$QT4DIR
$ export PATH=$QTDIR/bin:$PATH
$ echo yes | ./configure -prefix /usr/local/qt4
$ make
$ sudo make install
$ mkdir $QTEDIR/bin
$ cp bin/uic $QTEDIR/bin/
$ export TMAKEPATH=$TMAKEDIR/lib/linux-g++
$ export QMAKESPEC=$QTDIR/mkspecs/linux-g++
$ export PATH=$PATH:/usr/local/qt4/bin
$ cd ~/project/sysapps/qt_embedded/host/qt-x11-opensource-src-4.4.3/tools/qvfb
$ qmake
$ make
$ sudo cp ../../bin/qvfb /usr/local/qt4/bin

close terminal to clear envs created earlier
open new one

$ export QTEDIR=/home/donal/project/sysapps/qt_embedded/host/qt-embedded-linux-opensource-src-4.4.3
$ cd $QTEDIR
$ export QTDIR=$QTEDIR
$ export PATH=$PATH:$QTDIR/bin
$ echo yes | ./configure -prefix /usr/local/qte4 -qvfb
$ make
$ sudo make install

//test framebuffer:
$ /usr/local/qt4/bin/qvfb

create new console/terminal window

$ cd ~project/sysapps/qt_embedded/host/qt-embedded-linux-opensource-src-4.4.3/examples/draganddrop/draggibleicons
$ ./draggableicons -qws //QTE needs sever, -qws means this application is the server

===================Cross compiling QT/E==================

new terminal

Step1: for tslib and autoconf support download and install in own computer

$ cd ~/project/downloads
$ wget [site was down so alternative location]
$ wget
$ cd ~/project/sysapps/
$ mkdir tslib
$ mkdir autoconf
$ cd autoconf
$ tar xzvf ~/project/downloads/autoconf-2.63.tar.gz
$ cd autoconf-2.63
$ ./configure
$ make && sudo make install
$ cd ../../tslib/
$ tar xzvf ~/project/downloads/tslib-1.0.tar.bz2
$ cd tslib-1.0
$ sudo apt-get install automake //seems to be needed
$ sudo apt-get install libtool  //seems to be needed
$ sudo ./
$ ./configure CC=arm-linux-gcc CXX=arm-linux-g++ PLUGIN_DIR=
/usr/local/linux-arm/plugins -prefix=/usr/local/linux-arm -host=arm-linux

I got an error during the make procedure about malloc and to resolve problem i found by editing config.h was the solution

$ edit config.h and comment out #define malloc rpl_malloc
$ make
$ sudo make install

Ensure that cross compiler is locatable
$ arm-linux-g++
if says no input files you sorted, else “export PATH=/path/to/cross/compiler:$PATH”

Use Qmake to create target specification

Note at this stage I was running out of space (df command said. I found that the host folder was about 6 gigs (du -s -h host) so I deleted all contents in this (rm -r ~/project/sysapps/host)

EDIT: Note!!!! – The TS7390 is a 16bit colour device but techically it is 15 bits. It ignores the least significant bit of the green bits. Its arrangement is: RRRRRGGGGGXBBBBBB so infact its RGB 565 but QT Embedded detects it as a 15 bit device since it gets 5 bits back for the length of the green colour. You will get dodgy colour here. Please look at one of my latest blogs on the hack on how to fix the colour before compiling.

$ cd ~/project/sysapps/qt_embedded/device
$ tar -xzvf ~/project/downloads/qt_embedded/qt-embedded-linux-opensource-src-4.4.3.tar.gz
$ cd qt-embedded-linux-opensource-src-4.4.3
$ export QTDIR=$PWD
$ echo yes | ./configure -embedded arm -xplatform qws/linux-arm-g++ -no-qvfb -depths all -qt-mouse-tslib -qt-kbd-usb -I/usr/local/arm/tslib/include -L/usr/local/arm/tslib/lib
$ make
$ sudo make install  //Installs in /usr/local/Trolltech/QT-Embedded-4.4.3-arm/

I havn’t tested this but doing a file command on some binaries in the demo example folders it said ARM type so that’s good at least. However doing file in the bin folder for qmake I got Intel 386 binary which definitely won’t work on the board but as far as I know these are not required anyways as only using libraries. Now to get this onto the board. The whole size of the folder is only 78MB so nice and compact. I bought a SD card to back up the other so now I will go messing about getting this on.

Sunday, January 25th, 2009 QT Embdedded Programming, Single Board Computer

7 Comments to Cross Compiled QT Embedded – Step by Step

  • Alberto Gomez says:

    Thanks a lot!!!!

    I had been searching like crazy for a guide on compiling QTE for the TS-TPC-7390, and this one even has the color correction patch!


  • admin says:

    Glad I could help, the colour issue was driving me insane. But got there in the end. I don’t think the Tmake has any importance, but added it anyways!

  • Edmondo says:

    You look like a real expert… Would you please, when you have the time, suggest the steps to follow to do that under windows? It is driving me crazy… I am not even able to mount the sd card on my board :( probably it is already mounted but i do not find the files i am looking for:(

  • Donal says:

    Sorry I only came across this comment now, did you have any luck on Windows? – are you using QT, as I believe with QT embedded you must use Linux, don’t think anyone done it successfully with Cygwin

  • kirk says:

    Hello Donal,

    I have exactly same feeling with you of the whole process. I have many questions to ask you and really hope you can help since your development progress was very similiar to mine. I used qt 4.5.2 to develop my app. with qextserialport class in linux pc and now really wanted to move it to arm-linux.

    1. Which qt-embedded version you suggest I used? or qtopia-core version?
    2. I already installed cross compiler 3.3.6-glibc-2.3.2. Is it too old for my app.?
    3. now when I compile the qextserialport class with qtopia-4.3.3 qmake, error came out …”build/obj/qextserialbase.o: could not read symbols: File in wrong format” .do u have any idea?
    4. If i can talk to you on gmail, that would be good.


  • Donal says:

    Don’t use Qtopia, that’s for phones and discont presently as far as I know. Everything is qt embedded now.

    You must download the QT embedded source and build it with the GCC 3 compiler. It’s not too old, it should work.

    Time is very limited for me at moment but if you have specific problems let me know and I can try help.

  • kirk says:

    thank for your quick reply as u know it is really a pain to stuck in the middle of it. So let me cut the words short

    1. As I said my final target is the arm board and I used qt-4.5.2(qtsdk-2009.03) to i using the wrong version since my idea is to develop with 4.5 first and then cross compile to qtopia-core-4.3.3-arm..

    2. why there is an error as I mentioned last message that when compiling qextserialport in 4.3.3 since it worked fine in qt 4.5.


  • Leave a Reply

    You must be logged in to post a comment.