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
qmake-qt4 -project
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
Compile!
make
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
the wine team is usually very interested in these kind of bugs (with source code and all).
don’t hesitate to report it to http://bugs.winehq.org/
Why the app looked bad? Doesn’t Qt uses native windows gdi?
It does. That’s why maybe it looks so lame 😀
It works.
Any suggestions to make postgres sql driver working under window ?
I got sqldriver notfound message
Nice!
I’ve always used a virtual machine for this kind of stuff but it’s cool to see other ways of doing it
Here is how to auto discover the needed DLLs (hope this looks ok in the comment):
DLLS=`i686-pc-mingw32-objdump -p release/*.exe | grep dll | awk ‘{print $3}’`
for i in $DLLS mingwm10.dll ; do
f=/usr/i686-pc-mingw32/sys-root/mingw/bin/$i
if [ ! -f $f ]; then continue; fi
cp -av $f release
done