I made school project in Qt4.5.3 and my teacher does not use Linux so I decided to try to cross-compile the project for her from Fedora 11. Here are the steps. Let’s hope it is useful for you too.
First you have to install mingw compiler, so I did something crazy like:
yum install mingw32*
That grabs everything related to mingw (installs Qt4 libs, compiler, qt-qmake specs files) on Fedora 11. Many unrelated libs are installed too (Gtk, …) – you have been warned.
Then you create Qt4 project file if you don’t have one already
Pass the qmake specification:
qmake-qt4 -spec fedora-win32-cross
Run this so that QtGui is found
QMAKESPEC=fedora-win32-cross qmake-qt4 QT_LIBINFIX=4
Then I found exe file in release/ directory. I wanted to distribute it so I needed to distribute some dlls too. To find out I run
i686-pc-mingw32-objdump -p prog.exe | grep dll
It lists all used dlls.I copied them from Fedora box to the same folder as the binary and I was done!
I used locate to find them (found in /usr/i686-pc-mingw32/sys-root/mingw/bin/). QtCore4.dll, QtGui4.dll and libgcc_s_sjlj-1.dll was needed for me.
I did not copied KERNEL32.dll, msvcrt.dll etc. Windows users usually have those files.
Then it worked for me. The app looked bad but worked as supposed to. In Wine it had some bug, but it worked on Windows XP.
Thanks for help to the fedora-mingw team at #fedora-mingw on freenode IRC 😉
https://fedoraproject.org/wiki/MinGW/Tips – related wiki page