Installing MinGW and MSYS

Download and run mingw-get-inst (the download link can be found in the previous section).

Select "Use pre-packaged repository catalogues".

Review and accept the License agreement.

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.

Select C++ Compiler and MSYS Basic System as optional components.

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:

C:

(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

Open the MinGW shell (MSYS) by running msys.bat.

Run the following commands:

make -v
gcc -v

They should output something. Check if something goes wrong.

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)

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.

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.

NoteThe 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.

WarningCompiling with libicu will greatly increase the size of the resulting OpenTTD executable.

Getting the source code

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

Start MSYS.

Run:

cd ~/<path_to_source>
./configure
make

(note that ~ means your MSYS home folder)

The compiling is complete when the openttd.exe file is made. It will be copied to the ./bin subfolder.

To test your compilation you can run (from the same folder in which you compiled OpenTTD):

./bin/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)

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: