toc next

MinGW32 Cross Compile

What you need

If you already have MinGW32 cross compile tools installed, you can skip this step. If not, there are a few ways of setting this up.
  1. Your distro has a xmingw package you might be able to use (I've never tried this).
  2. You could get the following binary: http://www.libsdl.org/extras/win32/cross/mingw32-linux-x86-glibc-2.2.tar.gz Which is a prebuilt of option 3. Though this binary targets i386 (rather than i586) and might be using an older version gcc (I've not tried this)
  3. Follow my instructions below to build a recent version of MinGW32 (recommended)
To build the cross compile system you need: You should be able to get these tools through your distribution's pakage manager. And you need to get my modified version of build-cross.sh (this was original found at http://www.libsdl.org/extras/win32/cross/build-cross.sh. My version is updated and modified to target i586 rather than i386). If you are interested in doing this manually, please take a look at the script, it should not be too hard to follow.

Step by Step Instructions

  1. put the downloaded build-cross.sh in a temporary directory with lots of free space.
  2. edit build-cross.sh with your favorite text file editor.
    1. un-comment or set PREFIX to the directory you want your MinGW32 cross tools to be installed in.
    2. un-comment DO_SU if you are installing into a directory that needs root access to write to it (you will be prompted for your root password 4 times)
    3. pick your favorite downloader by uncommenting one of the lines starting with DOWNLOADER or set it to your command line download program
    4. set CFLAGS to optimisations that make sense for your platform, I'd recommend "-O3 -march=your_cpu", where your_cpu is the type of processor you are using.
    5. pick your favorite MinGW32 mirror by uncommenting one of the lines starting with MINGW_URL
    6. save and exit
  3. do the following at a shell in the directory you placed build-cross.sh:
    chmod +x build-cross.sh./build-cross.sh
  4. The script will now download, build and install the MinGW32 cross compile tools. If you set the DO_SU variable it will prompt you for your password 4 times to gain root access to install the tools.

Convenient Scripts

There are two scripts which I find really convenient: cross-configure.sh and cross-make.sh, you can get them here: You will need to modify these scripts to point to where your cross tools are installed by changing the PREFIX and TARGET variables in the scripts to match what is in your build-cross.sh script. And put them in a directory somewhere in your path so that you can use them like any other command (you could copy them to your /usr/bin directory for example).

Other MinGW32 Cross Compile Instructions

There are other MinGW32 cross compile instructions found at:

I have never tried any of these instructions.


toc next