I’ve been trying to get cross-compiling to work on my linux box for quite some time now.
Now that it’s finally working, I decided it was something that had to be shared :D
I wanted to cross-compile to build nightlies for a new, open-source and cross-platform p2p application
:)
To be clear, I’m not trying to write a full tutorial, just some basic guidelines to get you started.
Step 1: Set up a MinGW cross-compile environment
Normally this would take some time, but you can get a script that does it all for you from
http://www.mingw.org/wiki/LinuxCrossMinGW.
$ sh x86-mingw32-build.sh
Follow the steps on your screen, this should be straight-forward.
For this guide, I assume you have installed MinGW in /home/user/mingw32/.
Step 2: Compile QT
We have two options here:
– Cross-compile QT on linux: don’t. It’ll take you too much time. There is a guide that covers this pretty well though on

Divided Mind
. It’s for an older QT version, I didn’t get it to work.
– Pre-compile QT on windows: this will take you far less time :) This is what I’ll try to cover a bit:
Install the SDK on your windows box (if you have QT Creator installed, you have the SDK already).
For me, QT was installed in C:Qt2010.02.1qt. (Mind the qt subdirectory!) Now copy this whole directory and transfer it to your linux box.
I will assume you have put the contents in /home/user/qtwin/, which should contain an “include” and “lib” directory.

Step 3: Modding QT on linux
You should have QT installed on your linux box as well. Amongst the lines I executed on my debian box were:
$ apt-get build-dep qt4-qmake
I also needed this one:
$ apt-get install libphonon-dev
Now find out where the QT “mkspecs” directory is located on your linux box.
$ find / -type d -name “mkspecs”
This should at least return the directory where APT installed QT, and the directory that you transfered to /home/user/qtwin.
The APT directory was /usr/share/qt4/mkspecs in my case. Changedir to it, now:
$ cp -r win32-g++ win32-x-g++
The win32-g++ directory (and now win32-x-g++ too) contain a file called qmake.conf. It tells QT which tools to use for compiling.
Standard, it uses windows tools (like “xcopy” and “del”). You have to replace the ones in win32-x-g++/qmake.conf with their linux counterpart.
You’ll also have to modifiy include and library dirs, and make it use the MinGW tools.
You can find my own modded qmake.conf on
pastebin
(it isn’t perfect, but will give you an idea). This is a very important step, so make sure to get it right
:)
Step 4: Compiling your application
Yes, we’re here already :)
Changedir to your project directory and execute:
$ qmake -spec win32-x-g++
So generally compile as you do usually but with another -spec flag.
$ make
And, see if it works!
Kudos:

Links that helped me a lot: