Compilar en Linux
/File/en/Translation.png
Este art铆culo se est谩 traduciendo del original en ingl茅s: en/Archive/Compilation and Ports/Compiling on GNU鈭昄inux and 馃焿BSD.
Porcentaje: 0% aprox.
  
Puedes colaborar ayudando a su mejora en la redacci贸n.
  • Usa el Manual de Estilo para una correcta edici贸n.
  • Recuerda quitar esta plantilla una vez que el art铆culo haya sido correctamente traducido.

A quick guide to get started with OpenTTD development on Linux and other Un*x-like systems. For help with compiling on various platforms, join #openttd on OFTC.

Contents

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.

Mandriva

(tested on Mandriva 2009 Spring)

Or enter the command:

urpmi gcc gcc-c++ libsdl-devel zlib1-devel subversion patch patchutils

Debian and Ubuntu

Or enter the command:

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

And for Ubuntu 9.04 and higher:

sudo apt-get install libsdl1.2debian-pulseaudio

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]

Fedora

(tested on FC6 and Fedora 7, 8 & 11)

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

SuSE 10.1

From YaST:

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:

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:

openSUSE 10.2

Use YaST to download:

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

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

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.

openSUSE 10.3

Use YaST to download:

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

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

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.

FreeBSD

To fetch, compile and install all necessary dependencies, as root run:

cd /usr/ports/games/openttd && make depends clean

If you are going to compile OpenTTD from subversion then again, as root run:

cd /usr/ports/devel/subversion && make install clean

NetBSD

To fetch, compile and install all necessary dependencies run:

cd /usr/pkgsrc/games/openttd && make depends clean

If you are going to compile OpenTTD from subversion then again run:

cd /usr/pkgsrc/devel/subversion-base && make install clean

You should be asked for the root password once the code is compiled and ready for installation.

Getting the source

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.

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.

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.

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.

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

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

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.

Reverting

You can undo changes to a file with:

$svn revert filename

or to your entire working directory with:

$svn revert -R .

Aplicar un parche

Para aplicar un parche (archivo diff) a su c贸digo fuente de OpenTTD, primero debe actualizar su c贸digo fuente a la revisi贸n del archivo-parche. Puede consultar la revisi贸n en las primeras l铆neas del parche, ejemplo:

Index: foo.c
===================================================================
--- foo.c (revision 1234)
+++ foo.c (working copy)
(En este ejemplo la revisi贸n es R1234)

Para actualizar su c贸digo fuente teclee:

$ svn update -r 1234

Ya est谩s listo para combinar (merge) el archivo-parche:

$ patch -p0 < mydiff.diff

Ahora (opcionalmente) actualice su c贸digo fuente a la revisi贸n m谩s reciente con:

$ svn update

Si esto provoca conflictos (archivos marcados con "C"), mala suerte, el parche no funciona con la 煤ltima revisi贸n (siempre puede retroceder y volver a intentar el parcheado, salt谩ndose el 煤ltimo paso y jugando una versi贸n anterior).

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.

Required data files

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

Windows version DOS version

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.

Playing the soundtrack

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

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.