Building Qt 4.6 for Maemo 5 apps on Mac OS X
December 26, 2009 by Harald Fernengel | Comments
Recently, the Maemo team released the preview of their new tool chain named MADDE. It allows building Maemo 5 applications also on Mac and Windows. Unfortunately, it currently only supports Qt 4.5.x, not the shiny new (and unstable) Qt 4.6 for Maemo 5. After a bit of fiddling I managed to to create a patch that allows building Qt 4.6 apps for Maemo 5 on Mac OS X.
Read on if you're into adventures, otherwise please stop reading here and wait for the official Qt 4.6 MADDE support packages :)
After downloading and installing MADDE, we first need to install the Qt 4.6 for Maemo 5 libraries. For that, we take the qt4-maemo5 Debian packages from repository.maemo.org. First, we need libqt4-maemo5-dev_4.6.0~git20091218-0maemo1_armel.deb. The Debian package can be decompressed with the ar x command. This extracts three files, but we only need data.tar.gz, which must be extracted in $HOME/.madde/0.5/sysroots/fremantle-qt-arm-sysroot-0942. To verify that everything went well, check the contents of $HOME/.madde/0.5/sysroots/fremantle-qt-arm-sysroot-0942/opt/qt4-maemo5/include, this directory should now contain all Qt header files. Repeat the unpacking for every Qt library that your project needs, starting with libqt4-maemo5-core_4.6.0~git20091218-0maemo1_armel.deb.
Almost there :) The host tools (qmake, moc, rcc, uic) in MADDE are from Qt 4.5.x, so we can't use them for Qt 4.6 development. Copying them from a Qt for Mac OS X installation is sub-optimal, since qmake is assuming that we're building Mac OS X applications. So, we also need the Qt sources that match the Debian packages. You can also grab them from repository.maemo.org (make sure the version+date of the source package matches the version+date of the binary packages you installed above). After uncompressing, apply this really ugly patch (*) and run the following commands:
# first, we need to configure Qt for Maemo 5, telling qmake to use the "madde" mkspec
./configure -maemo5 -xplatform linux-g++-madde -x11 --force-pkg-config -no-opengl --prefix=/opt/qt4-maemo5
# install qmake and the mkspecs
sudo make install_mkspecs install_qmake
# build the other tools (moc, rcc, uic)
cd src/tools
../../bin/qmake -spec ../../mkspecs/macx-g++ -r -macx -o Makefile tools.pro
make
sudo make install
Now, we should have qmake, moc, rcc and uic in /opt/qt4-maemo5/bin on our Mac OS X host.
Make sure that the mad command is in your PATH, then go to your project and run /opt/qt4-maemo5/bin/qmake. Do not run mad qmake, since that'll invoke the Qt 4.5.x qmake. Now, we can just type make to build the project. Note that instead of running g++, we'll invoke mad g++ to create an ARM binary. After compilation, you can check your binary with the file command. The output should look something like that:
ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8
If you've got this far, congratulations, you've built a Qt 4.6 for Maemo 5 application on Mac OS X :)
Complex? Yes, it is :) But no worries, we plan full support for MADDE without having to mess around with patching and manually uncompressing things. I even heard rumors that a Qt Creator + MADDE blog will surface soon :)
(*) Disclaimer: The patch was done after a lot of Christmas festivities including lots of food. Given the amount of things I ate, I estimate that 90% of the work was influenced by my stomach, with my brain being only partially involved
Blog Topics:
Comments
Subscribe to our newsletter
Subscribe Newsletter
Try Qt 6.9 Now!
Download the latest release here: www.qt.io/download.
Qt 6.9 is now available, with new features and improvements for application developers and device creators.
We're Hiring
Check out all our open positions here and follow us on Instagram to see what it's like to be #QtPeople.
Commenting for this post has ended.
This is good news and I just can't wait for the moment when I can build my Qt application on WinXP for Maemo 5 (N900). Any chance that there will be an emulator on Windows? I guess I'm not adventurous enough to try the steps described, so I'll wait for the 'official' release.
Hey Harald, I was able to set my environment up according to your steps, but some additional work was required:
Move away $HOME/.madde/0.5/sysroots/fremantle-qt-arm-sysroot-0942/usr/lib/libQt*. This is necessary because otherwise the linker picks Qt 4.5 up. The generated linker command is mad g++ -Wl,-rpath-link,/usr/lib -Wl,-rpath,/opt/qt4-maemo5/lib ...
libQtGui.so links against libEGL.so which is not present in the MADDE sysroot. Copying it from a N900 fixes the problem, but I'm not sure if this is actually allowed.
Great to see new Qt experiments coming up. Will give it a try soon.
But I'm really interested to find out more about Qt Creator + MADDE for developing apps on Windows. It would be great if you guys can make the installation of Qt development environment as easy as possible.
So far I'm just reading stuff and saving lots of resources and examples. Will do some "Hello World" apps soon.
// chall3ng3r //
I am also eagerly awaiting a Qt-Creator / MADDE combination. Direct Maemo / ARM compilation from my production box would be so very sweet! Thanks for pushing the boundaries and I'm keeping my eyes peeled for that blog :)
I automate Power Plants with a 3d interface and I'm going to put the entire Power Plant automation system on my N900 so it can be seen and controlled remotely. But first, I'm waiting for Qt Creator and Maemo, I'm a 100% sure it's coming. It's just to big a system to debug from the command line and it's just so attractive for Nokia, I just can't see them passing that one up. After that, homes, planes, trains and automobiles, all in 3d.
@Stephan: You're right, libEGL must be copied from the device to MADDE first (see bug https://bugs.maemo.org/show...).
As for removing Qt 4.5, I didn't hit the bug because I only compiled wiggly which doesn't use symbols from 4.6 ;) Anyways, I've reported the bug at https://bugs.maemo.org/show...
Happy Hacking,
Harald
As Harald just told me, there are updated libqt4-maemo5 debs in the repositories (20100111). Here is a small bash script to unpack and install them all at once to your MADDE sysroot. This script assumes that you downloaded the files to ~/Downloads and you are in a temporary directory.
!/bin/bash
for i in ~/Downloads/libqt4-maemo5*.deb ; do
ar x "$i"
tar -C ~/.madde/0.5/sysroots/fremantle-qt-arm-sysroot-0942 -xvf data.tar.gz
done