Qt Cross compilation for ARM (on Ubuntu)

To build Qt for embedded Linux, you need to install a cross compiler on your system. I use Ubuntu 13.04 and did the following:

apt-get install g++-4.7-arm-linux-gnueabi gcc-4.7-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-arm-linux-gnueabi

You also need to download the Qt package for embedded linux – http://qt-project.org/downloads

Extract the package:

cd /tmp ; tar zxf qt-everywhere-opensource-src-4.8.4.tar.gz

Then it is time to adapt the platform files so that the correct compiler is used. Edit qt-everywhere-opensource-src-4.8.4/mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf

Change the into the following values:

# modifications to g++.conf
QMAKE_CC = arm-linux-gnueabi-gcc
QMAKE_CXX = arm-linux-gnueabi-g++
QMAKE_LINK = arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy
QMAKE_STRIP = arm-linux-gnueabi-strip
QMAKE_LIBS_THREAD += -lpthread -lrt -ldl

Then, it is time to configure Qt:

./configure -opensource -confirm-license -embedded -xplatform qws/linux-arm-gnueabi-g++ -nomake demos -nomake examples -little-endian -no-qt3support -no-cups -no-largefile -optimized-qmake -no-openssl -nomake tools -no-webkit -fast -no-gif -no-libmng -no-libtiff

Then, compile the code….

make

Then install the code

make install