Native MinGW

NoteShould work analogously on Mac OS X, please test

You will need the MinGW binaries, includes and libraries for Linux-to-Windows cross-compiling (32-bit, 64-bit not tested) installed under /usr/i586-mingw32msvc (Debian/Ubuntu: sudo apt-get install mingw32). The further steps are more or less the same as those required for compiling with MinGW on Windows.

For consistency, self-installed libraries etc. will be stored in subfolders of /usr/local/i586-mingw32msvc. However, the OpenTTD configure script isn't very good at finding libraries that match the selected host, so some will need to be specified manually/linked to a hardcoded directory (see end).

64-bit builds

Work exactly the same way, but with all occurences of i586-mingw32msvc replaced by x86_64-w64-mingw32 (you will need 64-bit MinGW, of course - Ubuntu: mingw-w64 package). You will need to link a few files to alternative names to be able to compile with ICU after you have built ICU:

If the build fails with error 'undefined reference to _free_locale', add parameter 'LIBS=-lmsvcr110' to 'configure' command line, this happens with ICU 58.2.

Getting the source code

Same as for standard Linux.

Compiling OpenTTD

NoteIf you are compiling for both 32 bit and 64 bit, make sure /mingw links to the correct folder for the current arch

Run:

cd ~/<path_to_source>
# Stupid hardcoded directories; you only need to do this once
# Note the missing slash at the end of the first argument, this is important
sudo ln -s /usr/local/i586-mingw32msvc /mingw
# This points pkg-config to our local mingw installation
export PKG_CONFIG_PATH=/usr/local/i586-mingw32msvc/lib/pkgconfig
# Also override freetype-config, icu-config etc with our own versions
export PATH=/usr/local/i586-mingw32msvc/bin:$PATH
# Configure, disable all libraries that are falsely detected, explicitly specify others
./configure --host=i586-mingw32msvc --prefix=/usr/local/i586-mingw32msvc CFLAGS="-I/usr/local/i586-mingw32msvc/include --sysroot=/usr/i586-mingw32msvc" \
LDFLAGS="-L/usr/local/i586-mingw32msvc/lib" --without-sdl --with-lzo2=/usr/local/i586-mingw32msvc/lib/liblzo2.a
make