0) Assumptions
This guide makes the assumption that you are running a Linux operating system (i.e. not Windows or Mac), specifically, a ***buntu distribution (e.g. Ubuntu, Kubuntu) - i.e. something that has apt-get on it.
If you're running a different Linux distro, see the note in step 1; otherwise everything should be the same.
Sorry, I've never compiled on Windows before, stay tuned for a guide on Cygwin!
If you're running a different Linux distro, see the note in step 1; otherwise everything should be the same.
Sorry, I've never compiled on Windows before, stay tuned for a guide on Cygwin!
1) Get the Dependencies
Before we do anything, we need to get all the "dependencies" - files that your computer needs to understand how to build Simutrans from the raw source code. Specifically, we need the "development libraries"; these are big chunks of code written by other developers that already do things like graphics (e.g. SDL).
These libraries are installed on your computer just like programs, using the Linux system's package manager.
The easiest way of doing this is by using the terminal - it sounds and looks scary, but don't panic - it's quite friendly!
These libraries are installed on your computer just like programs, using the Linux system's package manager.
The easiest way of doing this is by using the terminal - it sounds and looks scary, but don't panic - it's quite friendly!
- Press Ctrl-Alt-t to get the terminal (it'll look a bit like the image left).
- The terminal works by typing commands, then running them by hitting return.
- For ***buntu users, type this command into the terminal: sudo apt-get update This command will make sure your computer knows where to find all the required updates and files. Then run sudo apt-get build-dep openttd This command just ordered the installation of all the dependencies of OpenTTD. Depending on how much stuff you've installed on your machine already, it may need several 10s of MB of downloads. "Errr... OpenTTD?!" Yeah, OpenTTD is quite similar to Simutrans in its requirements, so much so that you can just use this command. (Incidentally, it is possible to use "build-dep simutrans", but I've then had things missing, and the compiling fails. I think this is because the version of Simutrans that apt-get tries to cover is pretty ancient).
- These commands require super-user privileges; it'll ask for the super-user password, which should be the same as your user password. Do be aware that the terminal won't show anything as you type your password!
- For non-***buntu users, check out this page on how to get OpenTTD's dependencies - it's a different game, but has near identical dependencies to Simutrans.
2) Get the Source Code
The best way of getting the latest source code is by using SVN - Subversion. This program downloads the latest code to a folder for you, but also keeps tab of what version is in that folder. Say you want to do this all over again for a later Simutrans version, or do it quite frequently, SVN will speed things up.
You may need to install SVN:
sudo apt-get install subversion
We now need to download the latest code: do this with this terminal command:
svn co svn://tron.yamagi.org/simutrans/simutrans/trunk
When asked for a password, simply hit return. When asked for a username, enter "anon", then hit return. When asked about storing the password unencrypted, type "y" then hit return (this is a publicly accessible server, so security doesn't matter here).
This will download the source code of the main (trunk) Simutrans code project into a folder called "trunk" in your home folder. If you want, you can then move this folder and call it something else. The terminal will show precisely what it is downloading; the entire source code is about 10 MB big. When its complete, SVN will tell you what version you downloaded or "checked out".
You may need to install SVN:
sudo apt-get install subversion
We now need to download the latest code: do this with this terminal command:
svn co svn://tron.yamagi.org/simutrans/simutrans/trunk
When asked for a password, simply hit return. When asked for a username, enter "anon", then hit return. When asked about storing the password unencrypted, type "y" then hit return (this is a publicly accessible server, so security doesn't matter here).
This will download the source code of the main (trunk) Simutrans code project into a folder called "trunk" in your home folder. If you want, you can then move this folder and call it something else. The terminal will show precisely what it is downloading; the entire source code is about 10 MB big. When its complete, SVN will tell you what version you downloaded or "checked out".
3) Prepare the Code
The Simutrans code is cross-platform, meaning it can be compiled by many different kinds of computers and in many different ways. You need to edit a particular file in the source code, in order to make the right kind of compiled "binary", the actual game file that will run on your computer.
Using a file explorer, go into your home folder, then into the "trunk" folder, wherever you put it. Look for a file called "config.template", then rename it "config.default".
Open config.default. This file is basically a settings menu that allows you to decide what program exactly you're going to make . It contains every option that can be chosen before the compiling process; each option is chosen by removing the # symbol in front of it.
Remove the # symbols in front of the following options:
BACKEND = sdl
This defines which graphics system we need. SDL works on most things.
COLOR_DEPTH = 16
Tells the compiler not to make a no-graphics multiplayer server instead!
OS_TYPE = linux
Don't think you can compile for Windows by changing the Windows line - you need a completely different set of programs for this!
OPTIMISE = 1
No idea what this does. "Umpteen" things apparently. They must be good as it's recommended to turn this on.
4) Compile!
Now, you need the command line terminal again. Navigate your way to wherever you put the "trunk" folder with all the source files in it. The following commands should help:
cd xyz
Opens the folder xyz.
cd ..
Goes back up one folder if you got lost.
ls -l
Shows all the files in a folder. If you're in the right place, you should see a lot of .cc and .h files.
All we need to do now is start the compilation process! Simply fire off this command:
make
Hopefully this worked!
If it did, look inside the folder /trunk/build/default. There should be somewhere a file called "sim" - this is your Simutrans executable, all ready to go!
Move this file into /trunk/simutrans. This folder is basically the actual installation of Simutrans that you're going to use. It is missing three things:
1) The executable "sim" file. You've made this and copied it into the folder, so this is now complete.
2) Language files. These need to be sorted out separately for some odd reason. Navigate to the "trunk" folder in the terminal and run this command: ./get_lang_files.sh Notice the "./" at the beginning. This shows you're firing off a command that is actually stored in the current folder (i.e. it's not a system command). This program puts the files into the Simutrans folder.
3) A .pak! You probably knew this, and know how to get them yourself. Simply put the pak*** folder into the "Simutrans" folder.
You now have a working build of Simutrans. Congratulations!
cd xyz
Opens the folder xyz.
cd ..
Goes back up one folder if you got lost.
ls -l
Shows all the files in a folder. If you're in the right place, you should see a lot of .cc and .h files.
All we need to do now is start the compilation process! Simply fire off this command:
make
Hopefully this worked!
If it did, look inside the folder /trunk/build/default. There should be somewhere a file called "sim" - this is your Simutrans executable, all ready to go!
Move this file into /trunk/simutrans. This folder is basically the actual installation of Simutrans that you're going to use. It is missing three things:
1) The executable "sim" file. You've made this and copied it into the folder, so this is now complete.
2) Language files. These need to be sorted out separately for some odd reason. Navigate to the "trunk" folder in the terminal and run this command: ./get_lang_files.sh Notice the "./" at the beginning. This shows you're firing off a command that is actually stored in the current folder (i.e. it's not a system command). This program puts the files into the Simutrans folder.
3) A .pak! You probably knew this, and know how to get them yourself. Simply put the pak*** folder into the "Simutrans" folder.
You now have a working build of Simutrans. Congratulations!