Loading...
 

Compiling Simutrans


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 Studiolink-external or MSYS2link-external. 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 link-external

Getting the Source Codelink

You can download the latest version with a SVN client. The primary repository for the Simutrans source code is
$ 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.

Getting the librarieslink


MSYS2 scriptlink

In the forum thread How to compile Simutrans with Msys2 (mingw64) link-external you can find a script by prissi link-external to setup and compile Simutrans. You may need to install “gcc” manually if compilation of miniupnpc fails.

MSYS2 manually / Linuxlink

  • For Linux/Unix you can use pkgs.orglink-external 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 sourcelink-external.
  • (**) 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


Library Website Debian/Ubuntu Arch Linux Fedora OpenSUSE MSYS2 Description
libzstd https://github.com/facebook/zstdlink-external libzstd-dev zstd libzstd-devel libzlib-devel Optional - Savegame compression
libpng http://www.libpng.org/pub/png/link-external libpng-dev libpng libpng-devel libpng16-devel mingw-w64-i686-libpng Optional - Used by makeobj
bzip2  http://www.bzip.org/downloads.htmllink-external libbz2-dev bzip2  bzip2-devel libbz2-devel Necessary
libfreetype http://www.freetype.org/link-external libfreetype6-dev freetype2  freetype-devel freetype2-devel mingw-w64-i686-freetype** Optional - Font support
libminiupnpc http://miniupnp.free.fr/link-external libminiupnpc-dev miniupnpc miniupnpc-devel miniupnpc-devel mingw-w64-i686-miniupnpc* Optional - Easy Server option
libSDL2  http://www.libsdl.org/link-external libsdl2-dev sdl2 SDL2-devel libSDL2-devel mingw-w64-i686-SDL2  Necessary
libSDL2_mixer http://www.libsdl.org/link-external libsdl2-mixer-dev sdl2_mixer SDL2_mixer-devel SDL2_mixer-devel Optional - MIDI playback on Linux
pkgconf http://pkgconf.org/link-external pkgconf pkgconf pkgconf pkgconf mingw-w64-i686-pkg-config Necessary for FreeType/SDL/makeobj


Microsoft Visual Studiolink

You can get a compressed file link-external 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 link-external.

Compilinglink


GCClink

  1. Go to the source code directory of simutrans
  2. 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)
  3. Additionally, you may want to set the following flags too:
Flag Description
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.

Microsoft Visual Studiolink

Simutrans solution is a single solution file with 4 projects:
  • 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.

Cross-Compilinglink

If you want to cross-compile Simutrans from Linux for Windows, see en_Cross-Compiling_Simutrans page.

Contributelink

If you want to contribute, read the coding guidelines in simutrans/documentation/coding_styles.txt
You definitely should check out the international forumlink-external as well.

Problemslink


Rate this page:

Contributors to this page: Roboron3042 , Frank , IgorEliezer and system .
Page last modified on Monday October 12, 2020 18:22:17 GMT-0000 by Roboron3042.

Online Users

19 online users

Newest Forum Posts

No records to display