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 updated nightly to reflect changes made to the svn repository the previous day.
How to compile Simutrans with Msys2 (mingw64) you can find a script by prissi to setup and compile Simutrans. You may need to install “gcc” manually if compilation of miniupnpc fails.
- For Linux/Unix you can use pkgs.org to search for packages if they are unlisted (or outdated) below.
- MSYS2 also needs make & mingw-w64-i686-gcc
- (*) On MSYS2, currently (10-2020) the miniupnpc version is broken and needs to be compiled from source.
- (**) On MSYS2, libbrotli static is broken but needed for freetype. You will need to execute the following:
for f in libbrotlidec libbrotlienc libbrotlicommon; do mv "$MINGW_PREFIX/lib/$f-static.a" "$MINGW_PREFIX/lib/$f.a" done
|libzstd||https://github.com/facebook/zstd||libzstd-dev||zstd||libzstd-devel||libzlib-devel||Optional - Savegame compression|
|libpng||http://www.libpng.org/pub/png/||libpng-dev||libpng||libpng-devel||libpng16-devel||mingw-w64-i686-libpng||Optional - Used by makeobj|
|libfreetype||http://www.freetype.org/||libfreetype6-dev||freetype2||freetype-devel||freetype2-devel||mingw-w64-i686-freetype**||Optional - Font support|
|libminiupnpc||http://miniupnp.free.fr/||libminiupnpc-dev||miniupnpc||miniupnpc-devel||miniupnpc-devel||mingw-w64-i686-miniupnpc*||Optional - Easy Server option|
|libSDL2_mixer||http://www.libsdl.org/||libsdl2-mixer-dev||sdl2_mixer||SDL2_mixer-devel||SDL2_mixer-devel||Optional - MIDI playback on Linux|
|pkgconf||http://pkgconf.org/||pkgconf||pkgconf||pkgconf||pkgconf||mingw-w64-i686-pkg-config||Necessary for FreeType/SDL/makeobj|
compressed file including the necessary dependencies, which are expected to work on Community 2015 version and newer. If you are using other version or prefer to compile the libraries yourself, check the forum thread .
- 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 (or “mixer_sdl2” for MIDI playback on Linux)
- 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|
Finally, type make. If you have multi-core CPU, you may want to compile with -jX option (where X is the number of cores).
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