Table of contents
- Getting the Source Code
- Getting the libraries
Normally you install and run Simutrans from one of the available executables, but if you wish to modify the source code yourself, and perhaps create patches and contribute to the development of the executable, you will need to be able to compile Simutrans yourself. This is a short guide on how to do just that.
If you are on Windows, download either Microsoft Visual Studio or MSYS2. MSVC is easy for debugging, MSYS2 is easy to set up (but it has to
be done on the command line).
These instruction are based on the readme.txt distributed with the source code. Please consult that document for any updates that might have been added since this page was last updated. You can also check the Development Support subforum
$ svn checkout svn://servers.simutrans.org/simutrans/trunk
If you prefer to use git, there is a mirror of the svn repository available thanks to aburch at github which you can make a local clone of:
$ git clone http://github.com/aburch/simutrans.git
Note that the svn repository is the main repository, and the git repository is just a mirror. If you use git instead of svn, you will need to set the game version manually for network play.
|zlib||https://zlib.net/||Necessary||Basic compression support|
|libSDL2||http://www.libsdl.org/||Necessary*||*On Linux & Mac. Optional but recommended for Windows. Graphics back-end|
|bzip2||http://www.bzip.org/downloads.html||Optional||Alternative compression. You can pick this or zstd|
|libzstd||https://github.com/facebook/zstd||Optional||Alternative compression. You can pick this or bzip2|
|pkgconf||http://pkgconf.org/||Optional||Needed by FreeType/SDL/makeobj|
|libpng||http://www.libpng.org/pub/png/||Optional||Used by makeobj|
|libfreetype||http://www.freetype.org/||Optional||TrueType font support|
|libminiupnpc||http://miniupnp.free.fr/||Optional||Easy Server option|
|libfluidsynth||https://www.fluidsynth.org/||Optional||MIDI playback with support for changing soundfonts. Recommended on Linux & Mac.|
|libSDL2_mixer||http://www.libsdl.org/||Optional||Alternative MIDI playback and sound system.|
- For Linux/Unix you can use pkgs.org to search for packages if they are unlisted (or outdated) below.
- For Mac you will need to install libraries via Homebrew .
- MSYS2 libraries marked with “*” need manual compiling/intervention.
|Library||Brew (Mac)||Debian/Ubuntu||Arch Linux||Fedora||OpenSUSE||MSYS2|
- Download MSVC Studio Community edition.
- Download a git tool and clone https://github.com/Microsoft/vcpkg to an arbitary directory (if you are using CMake the “build” directory is recommended).
- Run bootstrap-vcpkg.bat
- Copy install-building-libs.bat from simutrans/trunk to this folder and execute it, or install libraries the libraries you want manually:
./vcpkg/vcpkg --triplet x64-windows-static install zlib bzip2 libpng ztsd sdl2 freetype miniupnpc fluidsynth
Change the triplet according to your system (for example, “x86-windows-static” for 32-bit builds).
If you are using other version or prefer to compile the libraries yourself, check this forum thread .
mkdir build && cd build
cmake -LH ..
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake -DCMAKE_BUILD_TYPE=Release -G "MSYS Makefiles" ..
cmake.exe .. -G "Visual Studio 16 2019" -A x64.
cmake --build .
cmake --build . --target install
cmake --build . --target simutrans --config Release
- Open a terminal and run autoreconf -ivf
- Now run ./configure
- Type make AV_FOUNDATION=1 to compile Simutrans*
- Also type make OSX/getversion
- AVFoundation must be specified on MacOS 10.12 or later, but the midi playback is currently broken. If you care about music try Fluidsynth (USE_FLUIDSYNTH_MIDI=1) instead.
- Open a terminal and run autoconf
- Now run ./configure
- Finally type make to compile Simutrans
- Go to the source code directory of simutrans
- Copy the file config.template to config.default and edit the file. You need to specify:
- BACKEND = sdl2
- OSTYPE = (you should know it)
- Additionally, you may want to set the following flags too:
|OPTIMISE=1||Add umpteen optimisation flags|
|DEBUG= 1||Up to 3, enable the debug build|
|MULTI_THREAD = 1||Enable multi-core CPU support|
|USE_FREETYPE = 1||Enable Truetype font support. Set also FREETYPE_CONFIG|
|FREETYPE_CONFIG=freetype-config||If it fails, try with FREETYPE_CONFIG=pkg-config freetype2|
|USE_UPNP = 1||Easy server hosting behind routers|
|USE_ZSTD = 1||Compression for savegames|
|USE_FLUIDSYNTH_MIDI = 1||Use Fluidsynth music backend for MIDI playback|
Finally, type make. If you want a smaller program and do not care about error messages, you can comment out #DEBUG=1 and run strip sim (Unix) or strip sim.exe (Windows) after compiling and linking.
- Simutrans-Main: The project that holds the shared, non back-end specific, files. All the followings use Main to build the specific back-end executables.
- Simutrans SDL2: Prefered backend for Simutrans.
- Simutrans GDI: Windows-only backend.
- Simutrans Server: Server backend with no graphical interface.
There are 3 compilation configurations for the main executable:
- Debug is meant for developing
- Stable is meant for compiling stable versions
- Release builds optimised code but using revision data just like debug. This is meant for creating optimised nightly builds for servers.
You definitely should check out the international forum as well.
- Building from source on AMD64 Linux: http://forum.simutrans.com/index.php?topic=945.0