Cross compiling for Windows using MinGW

From OdaWiki
Jump to: navigation, search

This document is written for Debian and Ubuntu users. The process should be similar for other distributions, but installing the prerequisites will most likely be different.


Step 1: Installing and configuring the prerequisites

In order to build Windows binaries, you'll need MinGW, SDL, and SDL_mixer. This tutorial also assumes you're building the latest revision, so you'll need Subversion.

Subversion and MinGW are in the repositories, so to install them, type:

sudo apt-get install mingw32 subversion

Odamex expects the g++ compiler to be named mingw32-g++, create a link:

sudo ln -s /usr/bin/i586-mingw32msvc-g++ /usr/bin/mingw32-g++

Download SDL and SDL_mixer:


Extract the archives:

tar zxvf SDL-devel-1.2.13-mingw32.tar.gz
unzip SDL.dll -d SDL-1.2.13/lib/

The sdl-config utility needs to be modified to contain the correct prefix:

mv SDL-1.2.13/bin/sdl-config SDL-1.2.13/bin/sdl-config.bak
cat SDL-1.2.13/bin/sdl-config.bak | \
    sed 's/\/Users\/hercules\/tmp\/SDL-1.2.13/\/usr\/i586-mingw32msvc/' \
    > SDL-1.2.13/bin/sdl-config
chmod +x SDL-1.2.13/bin/sdl-config

Move the files where they belong:

sudo mv SDL-1.2.13/bin/sdl-config /usr/i586-mingw32msvc/bin/
sudo mv SDL-1.2.13/include/SDL/* /usr/i586-mingw32msvc/include/
sudo mv SDL-1.2.13/lib/* /usr/i586-mingw32msvc/lib/
sudo mv SDL_mixer-1.2.8/include/* /usr/i586-mingw32msvc/include/
sudo mv SDL_mixer-1.2.8/lib/* /usr/i586-mingw32msvc/lib/

You don't need the archives or what's left of their contents anymore. Delete them:

rm -rf SDL-1.2.13 SDL_mixer-1.2.8 SDL-devel-1.2.13-mingw32.tar.gz \

Step 2: Downloading the source

Use Subversion to check out a copy of the source:

svn co odamex-win32

Change to the source directory:

cd odamex-win32

Step 3: Compiling

Add the MinGW bin directory to your PATH so that the correct sdl-config is used:


And compile:

make -f

Step 4: Installing

The exe files are in the bin directory. A few more files are still needed to run in Windows. Copy them there:

cp /usr/i586-mingw32msvc/lib/SDL.dll /usr/i586-mingw32msvc/lib/SDL_mixer.dll \
    README odamex.wad odasrv.cfg bin/

You're all done! Copy the bin directory to a Windows machine and enjoy.

Personal tools