Compiling on Windows using MinGW
This article is for historical purposes only, and as a result is protected against further edits.

This guide is about MinGW/MSYS1, which is very old and not maintained any longer. It's much better, and easier, to use Compiling on Windows using MSYS2



This page contains guidelines for compiling OpenTTD for Win32 with MinGW.

List of packages

This tutorial has been tested with the following versions of the required packages:

Installing MinGW and MSYS

  1. Download and run mingw-get-inst (the download link can be found in the previous section).
  2. Select "Use pre-packaged repository catalogues".
  3. Review and accept the License agreement.
  4. Please note that MinGW should be installed to a directory path that doesn't contain any spaces. This method has been tested with a directory path of C:\MinGW.
  5. Select C++ Compiler and MSYS Basic System as optional components.
  6. Wait until every package has been downloaded and installation is finished.

Setting up MSYS

Go to your MSYS folder (found at <MinGW installation folder>\msys\1.0, C:\MinGW\msys\1.0 in this example), open etc\fstab with a text editor (for example Notepad) and add the following line at the end of the file:
C:\MinGW\   /usr/local

On Windows Vista and newer, you'll need additional steps to make MSYS fully work if User Account Control is enabled (it is by default). Go to your MSYS folder (C:\MinGW\msys\1.0 here), open msys.bat with a text editor (right-click -> Open With -> Notepad or equivalents) and add the following line after @echo off:

cd "C:\MinGW\msys\1.0"

And if your MSYS installation drive is not the disk Windows is installed on, add one more line:


(MSYS drive) After saving the file, right click on msys.bat and choose "Run as Administrator". You will need to do this every time you run MSYS. After that, programs requiring admin rights (such as install and patch) will work.

Testing MinGW/MSYS installation

If you get the error

gcc: command not found

browse your MinGW directory to msys\1.0\postinstall and run pi.bat

Compilation and installation of the required packages

For additional information about the libraries, check part 7.1) of OpenTTD Readme. To compile and install these packages and avoid the error 'wget: command not found', first you need to install the following commands: (To compile on Windows 7, the service "application experience" must be activated and running)

You can copy and paste into MingW windows by using CTRL+INS istead of CTRL+V


mingw-get install msys-wget
mingw-get install msys-unzip
mingw-get install msys-patch

If you get following error: configure: error: cannot run C compiled programs. , one of the reasons could be your anti-virus, that silently deletes a.exe binary files. Try to temporarily disable anti-virus software and compile again.

Installing Subversion


wget --no-check-certificate
cd svn-win32-1.7.6
mv bin/* /usr/local/bin/
cd ..

Compiling zlib


tar xvfz zlib-1.2.11.tar.gz
cd zlib-1.2.11
make -f win32/Makefile.gcc BINARY_PATH=/bin INCLUDE_PATH=/usr/local/include LIBRARY_PATH=/usr/local/lib install
cd ..

If your not able to compile it with the command line commands above you could try installing it with the "MinGW Installation Manager", its called: mingw32-libz. If wget is unable to find the server, the maintainers have probably moved up to another rev. Go to to see the new rev and then simply change all instances of 1.2.11 to the new rev (1.2.[rr]).

Compiling libpng


wget --no-check-certificate
tar xvfJ libpng-1.5.16.tar.xz
cd libpng-1.5.16
make install
cd ..

Compiling liblzo2


tar xvfz lzo-2.06.tar.gz
cd lzo-2.06
./configure --enable-static
make install
cd ..

Compiling libfreetype


wget --no-check-certificate
tar zxvf freetype-2.4.10.tar.gz
cd freetype-2.4.10
./configure --enable-static
make install
cd ..

Compiling xz

Liblzma (which is a part of xz) is required for compiling OpenTTD since r21044. It also needs pkg-config and its dependencies. In MSYS:

unzip -d /usr/local
unzip -d /usr/local
unzip -d /usr/local
wget --no-check-certificate
tar xvfz xz-5.0.4.tar.gz
cd xz-5.0.4
./configure --enable-static --disable-threads
make install
cd ..

Compiling libicu

libicu is an optional library used for handling of right-to-left scripts (e.g. Arabic and Persian) and the natural sorting of lists. It can take a long time to compile, so you can safely omit this step if you don't require libicu.

The application of the second patch is an optional step. It will reduce the size of compiled OpenTTD, at the cost of losing sorting data for most languages.
Compiling with libicu will greatly increase the size of the resulting OpenTTD executable.

openttd.exe size with libicu:approx. 25 MB
openttd.exe size with libicu (reduced icudata size):approx. 10 MB
openttd.exe size without libicu:approx. 8 MB


cd icu
patch -p1 -i libicu_4_8_mingw32.diff
patch -p1 -i libicu_reduce_icudata_size.diff
cd source
./configure --enable-static --disable-shared --disable-strict --disable-threads
make install
cd ../..

Getting the source code

Open the MSYS shell and run

cd && git clone

The OpenTTD source code is now in the trunk subdirectory of your MSYS home folder (<MinGW installation folder>\MSYS\1.0\home\<your Windows user name>).

Compiling OpenTTD

  1. Start MSYS.
  2. Run:
    cd ~/<path_to_source>
    (note that ~ means your MSYS home folder)
  3. The compiling is complete when the openttd.exe file is made. It will be copied to the ./bin subfolder.
  4. To test your compilation you can run (from the same folder in which you compiled OpenTTD):
    Don't forget to install a base graphics set before this step if you don't have one (the simplest solution is to install OpenGFX)
  5. If you want to generate a installation bundle you can use:
    make bundle
    After this command is done you will find a complete OpenTTD ready for distribution in the ~/<path_to_source>/bundle folder.

Patching the source code

Place the patch you want to apply into the directory the OpenTTD source code is located in (<MinGW installation folder>\MSYS\1.0\home\<your Windows user name>\trunk in this example). Then, in the MSYS shell:

cd ~/trunk
patch -p1/p0 < <patch name>

Use p0 for Subversion style patches, p1 for all others (it's probably a good idea to try p1 first). Explanation of the difference: FAQ development#how-to-apply-a-patch