Table of contents
- Getting the Source Code
- Getting the libraries
- Compiling with CMake
- Compiling with make
- Compiling with Microsoft Visual Studio
Normally you install and run Simutrans from one of the available downloads, 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 sub-forum
$ 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|
|bzip2||https://www.bzip.org/downloads.html||Necessary||Alternative compression. You can pick this or zstd|
|libSDL2||http://www.libsdl.org/||Necessary*||*On Linux & Mac. Optional but recommended for Windows. Graphics back-end|
|pkgconf||http://pkgconf.org/||Optional||Needed by FreeType/SDL/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 recommended on Linux & temporarily on 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 arbitrary directory that we will call vcpkg-root.
- Run bootstrap-vcpkg.bat
- Copy install-building-libs.bat from simutrans/trunk to this folder and execute it, or install the libraries you want manually:
./vcpkg/vcpkg --triplet x64-windows-static install zlib bzip2 libpng zstd sdl2 freetype miniupnpc
Change the triplet according to your system (for example, “x86-windows-static” for 32-bit builds).
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 -DCMAKE_TOOLCHAIN_FILE=[vcpkg-root]/scripts/buildsystems/vcpkg.cmake
If you are using the GUI, Visual Studio will try to generate the cache automatically if you open the simutrans source directory, but it will probably fail if you have not set the path to vcpkg toolcchain. So first go to Project -> Configuration and set the “CMake toolchain file” to “vcpkg-root/scripts/buildsystems/vcpkg.cmake” and the re-generate the cache with Project -> Generate Cache.
cmake --build . --target install
In MacOS --target install will also generate an app bundle.
cmake --build . --target install --config Release
If you are using the GUI, you can select Compile -> Install simutrans to do the same.
2. Unpack the unicode version of the plugins in /msys64/mingw64/share/nsis/unicode
2. Install NSIS in the default location (Program Files (x86))
3. Install the plugins either unpacking manually the unicode version in /Program Files (x86)/NSIS/Plugins/x86-unicode or by running in Powershell the prepare-nsis.ps1 script you can find in the .github directory of simutrans source code.
- 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: Preferred back-end for Simutrans.
- Simutrans GDI: Windows-only back-end.
- Simutrans Server: Server back-end 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 optimized code but using revision data just like debug. This is meant for creating optimized 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