Qt Cross Compiling for ARM platforms

Prepare cross compile toolchain

For Ubuntu Maverick, the arm cross compile toolchain can be installed as below:

$ sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi

The cross compile toolchain provided by different vendors with their BSP can also be used.

Prepare root file system for ARM platforms

The simplest way to create a rootfs for ARM platforms is to copy some necessary directories (/lib, /usr/lib and /usr/include) directly from ARM products (i.e, Efika Smart Book).

Note: Some libraries in /usr/lib are soft links to libraries in /lib directory, and absolute path is used for the link. So these soft links should be changed to use relative path for cross compiling.

Besides, some tools can be used to generate a new armel rootfs, such as rootstock, yocto, scratch box.

Download latest source code

The latest qt source code is located at http://qt.gitorious.org/qt. Sync the source tree to local directory and switch to the master branch.

$ git clone git://gitorious.org/qt/qt.git

$ git checkout -b master master

Create new mkspec

We can create a new mkspec using linux-g++ as template.

$ cd qt/mkspecs

$ cp -R linux-g++ linux-arm-g++

Then edit the qmake.conf in the linux-arm-g++ directory, add following settings before "load(qt_config)".

QMAKE_CC = $CROSS_COMPILE-gcc

QMAKE_CXX = $CROSS_COMPILE-g++

QMAKE_LINK = $CROSS_COMPILE-g++

QMAKE_LINK_SHLIB = $CROSS_COMPILE-g++

QMAKE_AR = $CROSS_COMPILE-ar cr

QMAKE_OBJCOPY = $CROSS_COMPILE-objcopy

QMAKE_STRIP = $CROSS_COMPILE-strip

QMAKE_LFLAGS_RELEASE = -Wl,-O1,-rpath $ROOTFS/usr/lib

QMAKE_INCDIR = $ROOTFS/usr/include

QMAKE_LIBDIR = $ROOTFS/usr/lib

QMAKE_INCDIR_X11 = $ROOTFS/usr/include

QMAKE_LIBDIR_X11 = $ROOTFS/usr/lib

QMAKE_INCDIR_OPENGL = $ROOTFS/usr/include

QMAKE_LIBDIR_OPENGL = $ROOTFS/usr/lib

Build Qt

A shadow build directory can be created to make the source directory clean.

$ cd qt && mkdir build

$ cd build && ./buildqt.sh

The content of buildqt.sh is given below:

#!/bin/bash

export CROSS_COMPILE=arm-linux-gnueabi

export ROOTFS=<path to the armel rootfs>

export QTDIR=<path to the qt source tree>

export PKG_CONFIG_PATH=$ROOTFS/usr/lib/pkgconfig

export PKG_CONFIG_SYSROOT=$ROOTFS

$QTDIR/configure -arch arm -xplatform linux-arm-g++ -force-pkg-config -prefix <install_prefix> -prefix-install -opengl es2

make

Note:

The "-prefix" and "-prefix-install" configure options are used for development build, and if you want to enable OpenGL ES2.0 for the opengl graphics system, please add "-opengl es2" option.

WorkingGroups/Middleware/Graphics/Qt/CrossCompiling (last modified 2011-02-28 02:19:36)