I’ve been looking for a way to compile an app developed with Qt Creator on Linux for Windows.
I came across this but I needed to tweak it before it worked so I decided to blog my own mini-guide (tested working with with Qt 4.6.3).
This assumes that you already have the Qt SDK (for Linux) installed.
- The first thing to do is download and install the MinGW cross compiler
- Then download the Windows version of the Qt SDK. As it’s distributed as a Win package, you’ll need to either install it on windows and copy the necessary files across to your linux distro (what I did) or install it through Wine (not sure if this even works). You can cross-compile it as well if you’re being adventurous
- Place the Qt Win SDK libraries in /usr/lib32/qt4win32 and headers in /usr/include/qt4win32
- Copy /usr/share/qt4/mkspecs/win32-g++/ to /usr/share/qt4/win32-x-g++/
- In the above directory, replace qmake.conf with the one found here
- Make sure that the paths in qmake.conf match those of your system (see NOTE below); specifically QMAKE_CXX, QMAKE_LINK, QMAKE_INCDIR, QMAKE_INCDIR_QT, QMAKE_LIBDIR_QT
- Run qmake adding –spec win32-x-g++ command line arg. This should cross-compile your app.
NOTE: As my linux box is a x86_64, my /usr/lib is /usr/lib32. Please adjust this accordingly for your setup.