GNU/Linux

From OpenTTD

(Redirected from Compiling on Linux)
Jump to: navigation, search


A quick guide to get started with OpenTTD development on Linux.

Contents

[edit] Required software

Most packages that are required for development (Like GCC) should already be installed on your box. You will require these packages in addition to GCC, make and the usual build tools. Beside those, OpenTTD requires the SDL development libraries to be installed. Optionally, but extremely recommended is install zlib development files, which compresses savegames (not having this doesn't just make your games bigger, but also makes you unable to load compressed savegames or join network games with compression, ie all network games). Lastly, OpenTTD can use the libpng development files to produce screenshots in PNG instead of BMP.

Furthermore, if you want to be as up to date as you can be, you should install the subversion client to access the latest code in our subversion repository.

[edit] Mandriva 2008

OpenTTD is available from Contrib media. So you can install it from the Control Center or on command line : 'urpmi openttd'. You have to install also 'timidity-patch-freepats' and 'TiMidity++' to enjoy the original game's music.

[edit] Debian and Ubuntu

  • build-essential (for compilers)
  • libsdl1.2-dev (required)
  • dpatch (required for at least 0.4.8)
  • zlib1g-dev (recommended, for savegame compression)
  • libpng12-dev (optional, for PNG screenshots)
  • subversion (optional, for getting the latest source)
  • timidity (optional, for playing the music)

Or enter the command:

sudo apt-get install build-essential libsdl1.2-dev subversion zlib1g-dev timidity dpatch

In at least one instance the package "libsdl1.2debian-all" was required for a full installation with a PowerPC build of Debian. Without this package, only the dedicated server would compile. [1]

[edit] Fedora Core

(tested on FC6 and Fedora 7 & Fedora 8)

  • gcc
  • gcc-c++
  • SDL-devel
  • zlib-devel
  • subversion (optional, for getting the latest source)
  • timidity++ (optional, for soundtrack)
  • esound (optional, for soundtrack)

Alternatively, if you have yum installed, issue the following command as root:

  • $ yum install gcc gcc-c++ SDL-devel zlib-devel subversion timidity++ esound -y

[edit] SuSE 10.1

From YaST:

  • gcc
  • gcc-c++
  • SDL-devel
  • zlib-devel
  • libpng-devel
  • subversion
  • timidity

You can install in a manner near identical to the apt method above for Debian if you have:

apt (if you installed apt4rpm from: [2] and the libs from: [3] by issuing the following command at the terminal:

  • apt-get install gcc gcc-c++ SDL-devel zlib-devel libpng-devel subversion timidity++

If this does not immediately work, try editing your /etc/apt/sources.list file with root and adding "packman suser-guru" to the end of the lines starting with "rpm"

Then, again as root, issue the following commands in order:

  • $ apt-get update
  • $ apt --no-checksig install rpmkeys* -y

[edit] openSUSE 10.2

Use YaST to download:

  • gcc
  • gcc-c++
  • SDL-devel
  • zlib-devel
  • libpng-devel
  • subversion
  • timidity

Alternatively, the console tool is known as `rug'. You may be able to get away with:

  • $ rug install gcc gcc-c++ SDL-devel zlib-devel libpng-devel subversion timidity

or if you have `smart' installed (see [4]):

  • $ smart install gcc gcc-c++ SDL-devel zlib-devel libpng-devel subversion timidity

The easiest way to set up smart is as follows, download the following from Guru's repository: [5] Download it to your desktop. login as root (in a terminal, type su followed by your root password) Browse to your desktop (cd ~/Desktop) Install the rpm (rpm -Uhv smart-0.51-9.guru.suse102.i686.rpm) Type smart, and and answer "Y" to all the repositories. This just saves you having to add them manually when you use Guru's version.

[edit] openSUSE 10.3

Use YaST to download:

  • gcc
  • gcc-c++
  • SDL-devel
  • zlib-devel
  • libpng-devel
  • subversion
  • timidity

You can use the command-line tool `zypper' as well:

  • $ zypper install gcc gcc-c++ SDL-devel zlib-devel libpng-devel subversion timidity

[edit] Gentoo

As root run $ emerge --onlydeps -av openttd and it will install all the OpenTTD dependencies.

If you want to use the most current version (aka TRUNK/SVN), run the following, again as root:

emerge subversion

[edit] Arch Linux

As root run $ pacman -S openttd and it will install all the OpenTTD dependencies.

There are also openttd-beta and openttd-svn PKGBUILDs available in the AUR.

[edit] Getting the source

[edit] Releases

You can download the .tar.gz source files from the OpenTTD website. Extracting tarball will give you a directory called openttd-<version>, where <version> is the version you downloaded. Enter this directory, and you're ready to proceed to step 3.

[edit] Nightly builds

Similar to the release option above, you can download the latest source snapshot (made every day at 1900 GMT) from the OpenTTD website. Unpack and enter the directory in which it is unpacked. Now, proceed to step 3.

[edit] Most current version (aka Trunk/SVN)

The most current version of the official code is stored in our subversion repository. Subversion makes it easy to track various versions and provides an easily shareable single location for our code. For you as a user this means you can quickly get the newest sourcecode.

[edit] Initial download

To obtain the source code from the subversion server type:

$ svn checkout svn://svn.openttd.org/trunk openttd

from command line to dump the code into the directory openttd/. We will refer to this directory as you "working copy" from now on. Also, all svn commands given from now on assume your working directory is the openttd/ directory.

You can now skip to step 3 if you just want to compile the latest version.

[edit] Updating

If you have previously downloaded the code and a new version is available (iow, new revisions have been committed), you can update your working copy to the latest version. Inside your working copy run the following:

$ svn update

Or, if you don't only want to update but also want to see what has changed, run our script that lists the changes:

$ ./svnup.sh

Also, if you have made any local changes to the source, these will be preserved and merged with changes in svn. If a conflict between the changes occurs, it will be flagged as conflicted (Marked "C" in svn status) (still preserving your local changes). For more information about resolving conflicts, look at the SVN Book at [6].

[edit] Creating a patch file

If you have made changes to your source that you want to share or upload as a patch, you can ask svn to generate a diff file. The command

$ svn diff > mypatch.diff

creates a diff file (also referred to as "patch") which you can submit to the developers to share your improvements.

[edit] Reverting

You can undo changes to a file with:

$svn revert filename

or to your entire working directory with:

$svn revert -R .

[edit] Applying a patch

To apply a patch (diff file) to the source code, update your source code to the patch file's revision. Let's say the patch file has been made on r1234. You can see this in the first lines of the patch:

Index: foo.c
===================================================================
--- foo.c (revision 1234)
+++ foo.c (working copy)

To update your source code to r1234, type

$ svn update -r 1234

Then you're ready to merge the patch file

$ patch -p0 < mydiff.diff

Now (optionally) update the source code to the newest revision with

$ svn update

If this produces conflicts (files marked with "C"), though luck, the patch doesn't work for the latest revision (you can always revert and retry the patching, skipping this last step and playing an older version).

[edit] Compiling and running

Compile OpenTTD with:

$ ./configure

This will create a Makefile, then:

$ make

If you have changed files or updated your source, this will only recompile modified code.

[edit] Required data files

Copy the GRF files from Transport Tycoon Deluxe to the data/ directory:

Windows version

  • sample.cat
  • trg1r.grf
  • trgcr.grf
  • trghr.grf
  • trgir.grf
  • trgtr.grf

DOS version

  • SAMPLE.CAT
  • TRG1.GRF
  • TRGC.GRF
  • TRGH.GRF
  • TRGI.GRF
  • TRGT.GRF

[edit] Running

You can run openttd with:

$ cd bin

$ ./openttd

The cd command brings you to the bin directory, where the openttd program has been put. Inside that directory, start the program.


Also, you can install the game in /usr/local/ or somewhere else, but this is mainly for packagers. This requires some more in-depth knowledge about installing software and OpenTTD, so look in the Makefile for hints.

[edit] Playing the soundtrack

[edit] With Timidity

If you want the original TTD music you need to copy the whole gm/ directory. Additionally the TiMidity program is required:

In Debian/Ubuntu

Download "timidity & freepats

sudo apt-get install timidity freepats

Start "System Setting" then click on the "Sound System" select the "Hardware" tab, click on the "Select the Midi Device" the Select the "Timidity port 0 - Alsa device" (tip: it may be different just search for timidity) then click the "apply" button.

In Fedora

Install timidity++

yum install timidity++ 

Timidity wants to talk to ESD, so you will need to "enable software sound mixing (ESD)" (System → Preferences → Sound).

To run OpenTTD with music support type

$ ./openttd -m extmidi

[edit] With Fluidsynth

In Debian/Ubuntu

Download Fluidsynth, Qsynth & Fluidsoundfonts

sudo apt-get install fluid-soundfont-gm fluid-soundfont-gs fluidsynth qsynth

Start Qsynth, (If you can`t find it in the menu, just type "qsynth" in the konsole) click Setup select the "soundfont" tab click open, navigate to "/usr/share/sounds/sf2/" and add both files find there, then select the "audio" tab and at the Audio Driver Menu select "Alsa" or "OSS" then click "OK, if it asks you to restart the engine, click yes, then click the "Options" button, then Check the "Enable system tray icon" then clcik the "X" button at the to right corner of the window.

Note: You must start Qsynth every time you start your computer!

[edit] Debian package

You should be able to build a Debian package from the latest source using the supplied debian directory. You can replace step 3 by this. This Debian directory is, conforming to OpenTTD standards, put inside the os/ directory and needs to be moved a level up first:

$ mv os/debian .

After that, use normal debian tools to build the package:

$ dpkg-buildpackage -rfakeroot -uc -us

Installing can then be done by executing (as root): $ dpkg -i ../openttd-<version>_<something>.deb

You now have OpenTTD installed.

In step 3 you need to copy the datafiles to /usr/share/games/openttd/data, since they are not included in the .deb due to licensing issues.

Instead of running OpenTTD as $ ./openttd, you can just type $ openttd to start it.

In step 5, you need to copy the music files from the gm directory into /usr/share/games/openttd.

Personal tools