Compiling on MinGW
From OpenTTD
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:
- MinGW-5.1.3
- binutils-2.16.91-20060119-1
- gcc-core-3.4.2-20040916-1
- gcc-g++-3.4.2-20040916-1
- mingw-runtime-3.12
- w32api-3.9
- MSYS-1.0.10
- wget-1.9.1 (from mingwPORT or sources) -> Needed to install mingwPORTs
- zlib-1.2.3 (from mingwPORT or sources)
- libpng-1.2.8 (from mingwPORT or sources)
- SVN, to retrieve latest OTTD code.
- MinGW-5.1.3
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.
- Run the MinGW 5.1.3 install file.
- 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.
- 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". Do you have MinGW installed? [yn ]
Input "y".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
- Create a new folder called local in the directory where MSYS is installed.
- 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
- Place wget-1.9.1-mingwPORT.tar.bz2 in a folder (e.g. /home).
- Start MSYS.
- 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. - It will download wget sources, compile and install them for you.
- Remove the temporary wget:
rm /usr/local/bin/wget.exe
[edit] Compiling zlib
- Place zlib-1.2.3-mingwPORT-1.tar.bz2 in a folder (e.g. /home)
- Start MSYS.
- 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. - It will download zlib sources, compile and install them for you.
- 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
- Place libpng-1.2.8-mingwPORT.tar.bz2 in a folder (e.g. /home)
- Start MSYS.
- 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. - 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:
- Start MSYS.
- 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.
- Start MSYS.
- Run:
cd ~/ottdsrc/trunk ./configure make
Some warnings may be shown, but they usually do not matter. - The compiling is complete when the openttd.exe file is made. It will be copied to the ./bin subfolder.
[edit] Testing OTTD
- Copy the following files from
(TTD)\data\to(OTTD)\data\:
sample.cat
trg1r.grf
trgcr.grf
trghr.grf
trgir.grf
trgtr.grf - Copy the folder
(TTD)\gmto(OTTD)\gm(Optional: only if you want music) - Run
openttd.exe. - Enjoy!

