Using CMake + Mingw to Cross-Compile Windows Apps (Part 2)

this is deprecated and have been long replaced by the mingw-w64 packages.

As promised, here's the second part of the tutorial on how to use cmake to build Qt4/OpenSSL Apps for Windows using mingw on Linux.

Assumptions :

1. You already followed the tutorial on how to setup Qt4/OpenSSL using mingw.
2. You have cmake installed.
3. You have a working wine setup or a way to test the executables.

Part 0 : Setup Wine

You can ignore this if you will test on windows.

  1. Run winecfg, go to Drives, add drive and set the path to your win32 dev (we will use the letter G for this).
  2. Run wine regedit, go to HKEY_LOCAL_MACHINE -> System -> Session Manager -> Enviroment -> edit PATH and append G:\qt-win-opensource-src-4.5.3\;G:\openssl-0.9.8l to the end.

Part 1 : Custom CMake Rules

We need to create a custom cmake rules file, we will name it lin-mingw.cmake for now :

Download the file.

Part 2 : Summon the Devil aka Call The Custom Rules

Now we need to call our custom rules file from CMakeLists.txt :

This way we don't polute CMakeLists.txt with all code which most likely will be the same for all the projects dpeending on it.

Part 3 : Testing it all

I created an example project, you can download it here.


Conclusion : If you are willing to spend some time setting this up, you won't need Windows to build your apps.

Wait for the next part on how to use NSIS to create Windows Installers.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTMLtags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">