Cygwin
From OpenTTD
[edit] Setting up Cygwin
- Download the Cygwin setup program from http://cygwin.com/setup.exe
- Choose to "Install from Internet".
- Select a directory to install to. The default, C:\cygwin, is a good choice.
- Select a directory to store the downloaded files in, for example C:\cygwin.ins.
- Choose a way to connect to the internet. "Direct Connection" will work for most people, but if you use a proxy, either choose "Use IE5 Settings" or manually fill in the proxy settings.
- Select a nearby mirror. For example, if you live in the UK, choose one with a .uk domain.
- Select the packages needed for compiling OpenTTD by clicking on the corresponding 'Skip' text. A package is already installed if the is a version number in the 'Current' column. The following packages are needed:
- In the Devel section, you will need:
- binutils: The GNU assembler, linker and binary utilities
- gcc: C compiler
- gcc-g++: GCC C++ compiler
- gcc-mingw-core: Mingw32 support headers and libraries for GCC
- gcc-mingw-g++: Mingw32 support headers and libraries for GCC C++
- make: The GNU version of the 'make' utility
- mingw-runtime: MinGW Runtime
- subversion: A version control system
- In the Libs section, you will need:
- crypt: Encryption/Decryption utility and library
- zlib: The zlib compression and decompression library
- mingw-runtime: MinGW Runtime
- w32api: Win32 API header and library import files
- In the Mingw section, you will need:
- mingw-zlib: mingw version of the zlib compression and decompression library.
- Optionally you might want to install:
- libpng12-devel from the Grahpics section for making PNG screenshots and loading PNG heightmaps.
- libfreetype2-devel from the Devel section for using Windows' font in OpenTTD.
- In the Devel section, you will need:
- Once you have done that, click Next and it will start to download. You can go and do something else as it will take a while if you have a slow connection. After the download finishes, Cygwin will be automatically installed.
- Cygwin uses a special way of accessing the normal windows filesystem. If, for example, you placed the OpenTTD source code at C:\openttd\, Cygwin sees that as /cygdrive/c/openttd/.
- Alternatively, if you got subversion - launch cygwin and run mkdir -p /usr/src/openttd to make the directory, then cd /usr/src/openttd and finally svn checkout svn://svn.openttd.org/trunk. This will place all the source code in /usr/src/openttd/trunk
- You can always get the latest source code by running command: svn update.
- Now you need to launch Cygwin, so use the start menu icon or run cygwin.bat in C:\cygwin. You then need to move to the folder where the source is, so type cd /usr/src/openttd/trunk.
- For the first time you need to do a ./configure to set up everything. If that gives errors in config.lib, run a dos2unix config.lib and try again. If you have installed libpng12-devel or libfreetype2-devel, you must add --disable-static to the parameters of ./configure.
- If you type make, the game should compile without errors. If you do get errors you missed something out or there is a problem with the code. If during the compilation an error occurs which says that it cannot find ft2build.h, copy /usr/include/ft2build.h to /usr/include/freetype2/. After this make should work ok
- You can now run the game by typing openttd.exe. If you get errors about DLLs you can find them in /bin or C:\cygwin\bin, just copy them into the directory where you OpenTTD source is. Also don't forget to copy the TTD files!
[edit] Editing the source
- You can edit the source with any Windows text editor (e.g. notepad etc.) or programming IDE but some of them have a tendency to add Windows-style CR-LF line returns. Editing within Cygwin is a bit of a pain when you have a full gui available. I recommend using Metapad, freeware available from http://www.liquidninja.com/metapad/ Metapad correctly handles UNIX/Windows line returns and is tiny and simple to use.
- You can recompile any changes you make as above. Just modify the source and then start from step 10: "Now you need to launch Cygwin".
[edit] FAQ
- Why doesn't my sound / music work now? It did in the nightly builds / release version!
This is because they use the SDL sound / music driver by default but this wasn't build with SDL. If your system doesn't support the win32 sound / music driver you will have no sound / music. Sound may work, but music may not (or vice versa).
- Why can't I save screenshots in PNG format?
This is because you did not build the game with PNG support, at the moment I am not sure how to do this because the PNG packages for Cygwin don't work (you can include libpng and it's development headers and manually edit the Makefile.config to make it compile but it fails at linkage with "undefined reference to __setjmp" errors).
- Why do I need the C++ compilers even though the game was written in C?
Because some of the Win32 DirectMusic files are C++ and other elements are also coded in C++ such as YAPF.
- Why does Cygwin bring up errors on first load about "unable to create directory /home/{something}?"
This is probably because your Windows username is set to something which is not allowed as a Window path, e.g. I set my Windows username to **** and you're not allowed a directory called that. The way to fix this is to add a line SET HOME=/home/admin to your CYGWIN.BAT file, before the login prompt.
Please note that the new network sometime has problems with the language-files (messagebox: "!String 0xE9684A ...") with a cygwin compiled exe.

