QtWebKit cross compilation with GCC for ARM-Linux

When I tried to cross compile QtWebKit for ARM-Linux, I didn't find any clear description, so I have decided to write a blogpost about it. It's not too hard, but if you have never done something like this, it can be a little bit confusing. In this post, I will describe this method in some simple steps.

Dependent libs and headers

The dependent libs can be found at

http://trac.webkit.org/wiki/BuildingQtOnLinux

Usually, you can get them from your device which you want to run QtWebKit on.
The following directories are needed:

  • /lib
  • /usr/lib
  • /usr/include

Put them to your SDK directory. (e.g. ~/SDKROOT)

GNU toolchain

For the cross compilation, you can use this GNU toolchain:

http://www.codesourcery.com/downloads/public/gnu_toolchain/arm-none-linu...

Unpack this to your toolchain directory. (e.g. ~/TOOLCHAIN)

Qt cross compilation

First download Qt-4.6.0 and unpack it.

wget ftp://ftp.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.0.tar.gz
tar -xf qt-everywhere-opensource-src-4.6.0.tar.gz

In your qt-everywhere-opensource-src-4.6.0/ directory, there are a lot of make specifications in mkspecs dir. You have to change the qws/linux-arm-g++ one. In this directory , look for qmake.conf and modify it as follows:

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++

# modifications to linux.conf
QMAKE_AR                = arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = arm-none-linux-gnueabi-objcopy
QMAKE_STRIP             = arm-none-linux-gnueabi-strip

Now, our Qt is ready for the compilation.
Qmake will be compiled with your g++ for x86 platform when you run ./configure, but qmake will generate make files which will use your ARM toolchain to build Qt libraries.

export PATH=~/TOOLCHAIN/arm-2008q3/bin:$PATH

cd qt-everywhere-opensource-src-4.6.0
./configure -arch arm -xplatform qws/linux-arm-g++ -release -openssl \
         -I~/SDKROOT/usr/include -L~/SDKROOT/usr/lib -L~/SDKROOT/lib \
         -lX11 -lxcb -lXau -lXdmcp -lXext \
         --prefix=/usr/local/Trolltech/Qt-4.6.0-arm-cross

make && make install

Now, you have a brand new cross compiled Qt.

QtWebKit cross compilation

QtWebKit cross compilation is very simple now. You just have to set up some environment variables, and then you are ready for the compilation with the build-webkit script.

QTDIR="/usr/local/Trolltech/Qt-4.6.0-arm-cross"   

export PATH=$QTDIR/bin:$PATH
export PATH=~/TOOLCHAIN/arm-2008q3/bin:$PATH

export BUILD_WEBKIT_ARGS="QMAKESPEC=qws/linux-arm-g++ DEFINES=QT_NO_UITOOLS LIBS+=-lm \
         LIBS*=-lsqlite3 LIBS*=-lexpat LIBS*=-lfreetype LIBS*=-lz LIBS*=-lXrender \
         QMAKE_CXXFLAGS+=-I~/SDKROOT/usr/include LIBS*=-L~/SDKROOT/usr/lib LIBS*=-L~/SDKROOT/lib"


cd WebKit
WebKitTools/Scripts/build-webkit --qt --release

Now, your QtWebKit is ready for running on your ARM device.

liubo_from china (not verified) - 05/22/2010 - 04:10

hi,I do the same job recently. Thanks for your help!
As I follow your process,I meet some problems.

First,I want to know the purpose of the dir SDKROOT,and what's the contents in them?

Second,when I did these:
./configure -arch arm -xplatform qws/linux-arm-g++ -release -openssl \
-I~/SDKROOT/usr/include -L~/SDKROOT/usr/lib -L~/SDKROOT/lib \
-lX11 -lxcb -lXau -lXdmcp -lXext \
--prefix=/usr/local/Trolltech/Qt-4.6.0-arm-cross
the system had a problems as,
ld:skipping incompatible ~/SDKROOT/usr/lib/libx11.so when searching for -lX11
ld:skipping incompatible ~/SDKROOT/usr/lib/libx11.a when searching for -lX11
cannot find -lX11
And I checked my host machine,Ubuntu9.10,the libX11-dev were the newest.
I don't know why?

Could you tell me your host system's version and your target?
Thanks again!

gabor.rapcsanyi - 05/25/2010 - 09:00

Hi!
The SDKROOT contains the ARM (target) libraries and headers. My host architecture is x86, and the target is ARM.
As I see you try to compile with x86 (host) libs and that cause this linker problem.
I get these ARM libraries from my target machine, but you can cross compile them one by one to your SDKROOT dir if you feel enough power in you :)

liubo_from china (not verified) - 05/26/2010 - 09:33

Thanks,I understand now. I believe that following you tips,I can do the work well by myself.Unfortunately,the time is not allowed.My tutor will check the port(WebKit to ARM) very soon.
So,if it's possible,please send your SDKROOT to me.Thanks a lot!
My email:xb_24@126.com

gabor.rapcsanyi - 05/27/2010 - 11:39

Sorry, but it's too big (~100MB) to send it in e-mail, so try to create an ARM chroot on your host machine and use this chroot libs and headers for the cross compilation.
A good starting point:
https://wiki.ubuntu.com/ARM/BuildEABIChroot

Olcay Ertaş (not verified) - 12/07/2011 - 01:06

Hi, I have tried to compile Qt as you described but encountered some problems. I have explained my problems here:

http://stackoverflow.com/questions/8401378/cross-compiling-a-qt-gui-appl...

Can you look at the problem and help me to find out a solution?

Thanks in advance.

Olcay Ertaş (not verified) - 12/07/2011 - 01:07

Here is the short link to question:

http://stackoverflow.com/q/8401378/614065

gabor.rapcsanyi - 12/08/2011 - 14:21

Hi, I'm not very familiar with Qt Creator but for the first look you should check libQtGui.so and the other libs whether they are compiled for ARM. The other thing is that I can't see what was the command which caused that error.

Anonymous (not verified) - 12/20/2011 - 10:38

Hi. can anyone please give me binaries for xrender (development files) and phonon (development files).

I couldn't cross compile them, and the apt-get install on arm brings many dependencies:(

gabor.rapcsanyi - 12/20/2011 - 13:22

Which distro do you use? The latest Ubuntu and Debian release are contain the correct version of these packages. You can download the Ubuntu ones from: https://launchpad.net/ubuntu/
But what is your problem with the dependencies?

Anonymous (not verified) - 12/20/2011 - 19:21

Thanks for answer.
I use Debian GNU/Linux 5.0 on my beagleboard, bbut when I tried
sudo apt-get install bison flex libqt4-dev libqt4-opengl-dev libphonon-dev libicu-dev libsqlite3-dev libxext-dev libxrender-dev gperf libfontconfig1-dev libphonon-dev g++

I got this

The following packages have unmet dependencies:
libicu-dev: Depends: libicu40 (= 4.0-1maemo2) but it is not going to be installed
libqt4-dev: Depends: libgconf2-6 (>= 2.13.5) but it is not going to be installed
Depends: libqt4-svg (= 4.5.3-1maemo1) but it is not going to be installed
Depends: libqt4-webkit (= 4.5.3-1maemo1) but it is not going to be installed
Depends: libqt4-scripttools (= 4.5.3-1maemo1) but it is not going to be installed
Depends: libqt4-xmlpatterns (= 4.5.3-1maemo1) but it is not going to be installed
Depends: libqt4-help (= 4.5.3-1maemo1) but it is not going to be installed
Depends: libqt4-assistant (= 4.5.3-1maemo1) but it is not going to be installed
Depends: libqt4-test (= 4.5.3-1maemo1) but it is not going to be installed
Depends: qt4-qmake (= 4.5.3-1maemo1) but it is not going to be installed
libqt4-network: Depends: libgconf2-6 (>= 2.13.5) but it is not going to be installed
libqt4-opengl-dev: Depends: libqt4-opengl (= 4.4.3-1+lenny1) but it is not going to be installed
Depends: libqt4-dev (= 4.4.3-1+lenny1) but 4.5.3-1maemo1 is to be installed
Depends: libgl1-mesa-dev but it is not going to be installed or
libgl-dev
Depends: libglu1-mesa-dev but it is not going to be installed or
libglu-dev
libqt4-qt3support: Depends: libgconf2-6 (>= 2.13.5) but it is not going to be installed
qt4-qtconfig: Depends: libgconf2-6 (>= 2.13.5) but it is not going to be installed
Depends: libqt4-phonon (= 4.5.3-1maemo1) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

So I try to cross compile those libraries
but couldn't do this for xrender and phonon.

p.s I have tried to build qt-4.8

Anonymous (not verified) - 12/20/2011 - 23:52

Also when cross compiling QT I got this

Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/vahag/QT/qt-everywhere-opensource-src-4.8.0/mkspecs/qws/linux-arm-g++.

Does it mean i have to cross compile Xlib too???

gabor.rapcsanyi - 01/05/2012 - 09:29

Hi!
Try to configure it with -v and you can get the exact problem, but anyway you need the Xlib for Qt compilation. But you should make an ARM rootfs instead of cross compile every lib you need. This is a good starting point: https://wiki.ubuntu.com/ARM/RootfsFromScratch

Anonymous (not verified) - 12/01/2012 - 02:06

Well, i am still new to linux even though linux hs been in the internet world or in this technology for a long time already. landscaping salt lake city

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • No HTML tags allowed
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Fill in the blank