Cross compile Qt-Apps for windows

I hate it to reboot my computer only to compile my qt apps for some windows users. And my vm doesn’t work anymore. So I was looking for a better way to solve my problem..

Well, i think you will have installed qt on your machine 😉 if not:

doep@doep ~ $ emerge -av x11-libs/qt-core

To build a win32 cross compiler crossdev would be helpful:

doep@doep ~ $ emerge -av sys-devel/crossdev

Now we can start with our gcc.  You have to do the following steps as root. To lists all supported architectures use:

doep ~ # crossdev -t help

The one we need is mingw32. Now we have to wait a bit until gcc, libc and binutils are ready.

doep ~ # crossdev -t mingw32

If no error occurs, gcc-config should create an output like this.

doep ~ # gcc-config -l
[1] mingw32-4.4.2 *
[2] i686-pc-linux-gnu-4.2.4
[3] i686-pc-linux-gnu-4.3.2 *
[4] i686-pc-linux-gnu-4.4.0
[5] x86_64-pc-linux-gnu-4.3.3
[6] x86_64-pc-linux-gnu-4.4.1 *

Download a windows qt version and install it. Then link the created folder to /usr/share/qt4win . You can also use wine to install the Qt package.

doep ~ # ln -s /mnt/win/Qt/4.5.0 /usr/share/qt4win

Now we have to create a qt spec folder in /usr/share/qt4/mkspecs/ called win32-x-g++. You can download the spec file here: win32-x-g++.tar

doep ~ # tar xvzf win32-x-g++.tar.gz -C /usr/share/qt4/mkspecs/

You are now ready to “try” to cross compile your program !! But first do a cleanup:

doep@doep ~ $ make distclean

Then tell qmake to use our win32-x-g++ spec:

doep@doep ~ $ qmake -spec win32-x-g++

And then start the compilation:

doep@doep ~ $ make -j4

Your application now needs the additionally libgcc_s_sjlj-1.dll to start. It’s located in:

/usr/x86_64-pc-linux-gnu/i686-mingw32/gcc-bin/4.4.0/libgcc_s_sjlj-1.dll
VN:F [1.9.22_1171]
Rating: 4.0/10 (2 votes cast)
Cross compile Qt-Apps for windows, 4.0 out of 10 based on 2 ratings

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Wir benutzen Cookies um die Nutzerfreundlichkeit der Webseite zu verbessen. Durch Deinen Besuch stimmst Du dem zu.