2OF1 · the depletionmode zineLinkedIn · X
← back to the issue

23 August 2010

Cross-compiling a Qt win32 app on Linux

Originally published on the old depletionmode / 2of1 blog (archived copy).

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 (this works 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 in 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

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 (this works with Qt 4.6.3).

This assumes that you already have the Qt SDK (for Linux) installed.

  1. The first thing to do is download and install the MinGW cross compiler
  2. Then download the windows version of the Qt SDK. As it’s distributed in 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
  3. Place the Qt Win SDK libraries in /usr/lib32/qt4win32 and headers in /usr/include/qt4win32
  4. Copy /usr/share/qt4/mkspecs/win32-g++/ to /usr/share/qt4/win32-x-g++/
  5. In the above directory, replace qmake.conf with the one found here
  6. 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
  7. 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 /usrlib is /usr/lib32. Please adjust this accordingly for your setup.

→ end of entry

2/1
@depletionmode
security research & systems engineering