Compiling on MinGW

From OpenTTD

Jump to: navigation, search

Contents

[edit] Introduction

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

[edit] Information

  • Source tested: OTTD trunk at revision 9788.
  • Packages used here:

All downloads combined is approximately 30MB and then you can expect another ~30MB of OTTD sourcecode. Expect a disk usage of about 250MB.

[edit] Setting up MinGW

Please note that MinGW should be installed to a directory path that doesn't contain any spaces.

  1. Run the MinGW 5.1.3 install file.
  2. On the install, select Candidate, then select the Minimal install plus the g++ compiler.

[edit] Setting up MSYS

Please note that MSYS should be installed to a directory path that doesn't contain any spaces.

  1. Run the MSYS install. You will see the following messages after GUI:
    This is a post install process that will try to normalize between
    your MinGW install if any as well as your previous MSYS installs
    if any.  I don't have any traps as aborts will not hurt anything.
    Do you wish to continue with the post install? [yn ]
    Input "y".
  2. Do you have MinGW installed? [yn ]
    Input "y".
  3. Please answer the following in the form of c:/foo/bar.
    Where is your MinGW installation?
    Input your MinGW installation path. If you mistyped it, the best solution for newbies is to re-install MSYS.

[edit] Install SVN

  1. Create a new folder called local in the directory where MSYS is installed.
  2. Unzip the folders bin, iconv, licenses, share from the SVN zip file and place into the new folder created in step 1

[edit] Testing the MinGW installation

  • Run MSYS.
  • Run the following commands:
    make -v
    gcc -v
    svn help
  • They should output something. Check if something goes wrong.

[edit] Compiling wget

  1. Place wget-1.9.1-mingwPORT.tar.bz2 in a folder (e.g. /home).
  2. Start MSYS.
  3. Make sure you are in the same directory where you placed the file and Run:
    tar -xvjf wget-1.9.1-mingwPORT.tar.bz2
    mkdir -p /usr/local/bin
    cd wget-1.9.1/mingwPORT
    cp wget.exe /usr/local/bin
    mkdir /usr/src
    ./mingwPORT.sh
    Answer the questions by pressing enter.
  4. It will download wget sources, compile and install them for you.
  5. Remove the temporary wget:
    rm /usr/local/bin/wget.exe

[edit] Compiling zlib

  1. Place zlib-1.2.3-mingwPORT-1.tar.bz2 in a folder (e.g. /home)
  2. Start MSYS.
  3. Make sure you are in the same directory where you placed the file and Run:
    tar -xvjf zlib-1.2.3-mingwPORT-1.tar.bz2
    cd zlib-1.2.3/mingwPORT
    ./mingwPORT.sh
    Answer the questions by just pressing enter.
  4. It will download zlib sources, compile and install them for you.
  5. Now its time to make the files available where they are needed. Run:
    mkdir /usr/local/include
    mkdir /usr/local/lib
    cp /mingw/include/zlib.h /usr/local/include
    cp /mingw/lib/libz.a /usr/local/lib

[edit] Compiling pnglib

  1. Place libpng-1.2.8-mingwPORT.tar.bz2 in a folder (e.g. /home)
  2. Start MSYS.
  3. Make sure you are in the same directory where you placed the file and Run:
    tar -xvjf libpng-1.2.8-mingwPORT.tar.bz2
    cd libpng-1.2.8/mingwPORT
    ./mingwPORT.sh
    Answer the questions by just pressing enter.
  4. It will download pnglib sources, compile and install them for you.

[edit] Getting the source

There are several ways to obtain the source:

This is one way:

  1. Start MSYS.
  2. Run:
    mkdir ~/ottdsrc
    cd ~/ottdsrc
    svn checkout svn://svn.openttd.org/trunk

[edit] Compiling OTTD

If you cannot compile, don't panic. Sometimes it may be due to coding errors.

  1. Start MSYS.
  2. Run:
    cd ~/ottdsrc/trunk
    ./configure
    make
    Some warnings may be shown, but they usually do not matter.
  3. The compiling is complete when the openttd.exe file is made. It will be copied to the ./bin subfolder.

[edit] Testing OTTD

  1. Copy the following files from (TTD)\data\ to (OTTD)\data\:
    sample.cat
    trg1r.grf
    trgcr.grf
    trghr.grf
    trgir.grf
    trgtr.grf
  2. Copy the folder (TTD)\gm to (OTTD)\gm (Optional: only if you want music)
  3. Run openttd.exe.
  4. Enjoy!
Personal tools