Cookie Consent

This website would like to place cookies on your computer to improve the quality of your experience of the site. To find out more about the cookies, see our privacy notice.

Loading...
 
Skip to main content

Site identity, navigation, etc.

Simutrans Tikiwiki
Simutrans Tikiwiki
The official wiki for Simutrans
I forgot my password
CapsLock is on.
  • Login with 2FA

Navigation and related functionality and content

(Cached)
Translations
English (en)Français (fr)
Structures
Development Index
Page actions
Refresh Print
  1. Development Index
  2. Compiling Simutrans

Table of contents

  • Getting the Source Code
  • Getting the libraries
    • Simutrans required libraries
    • Libraries for MSYS2 / Linux / Mac
    • Libraries for Microsoft Visual Studio
  • Compiling
    • Compiling with CMake
      • 1. Generate build files
        • Linux & MacOS
        • MSYS MinGW
        • MSVC
      • 2. Build Simutrans
        • Linux /MinGW/MacOS
        • MSVC
    • Compiling with make
      • MacOS
      • GCC Systems
      • Manual configuration with make
    • Compiling with Microsoft Visual Studio
  • Cross-Compiling
  • Distribution
    • (Windows only) Setting up NSIS
      • MinGW
      • MSVC
    • Prepare the distribution
      • Mingw/Linux/Mac
      • CMake
  • Contribute
  • Problems

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

Getting the Source Code

You can download the latest version with a SVN client. The primary repository for the Simutrans source code is

Copy to clipboard
$ 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:

Copy to clipboard
$ 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.

Getting the libraries

Simutrans required libraries

This is a list of libraries used by Simutrans. Not all of them are necessary, some are optional, so pick them according to your needs.

Library Website Necessary? Notes
zlib https://zlib.net/ Necessary Basic compression support
bzip2 https://www.bzip.org/downloads.html Necessary Alternative compression. You can pick this or zstd
libpng http://www.libpng.org/pub/png/ Necessary Image manipulation
libSDL2 http://www.libsdl.org/ Necessary* *On Linux & Mac. Optional but recommended for Windows. Graphics back-end
libzstd https://github.com/facebook/zstd Optional Alternative compression (larger save files than bzip2, but faster)
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.
libfontconfig https://www.fontconfig.org/ Optional Font autodetection (Linux/Mac)

Libraries for MSYS2 / Linux / Mac

  • You'll additionally need pkgconf installed (it usually comes pre-installed).
  • 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.
    • Check How to compile Simutrans with Msys2 (mingw64) and the script by prissi to get the libraries automatically.
    • You may need to install "gcc" manually if compilation of miniupnpc fails.

Library Brew (Mac) Debian/Ubuntu Arch Linux Fedora OpenSUSE MSYS2
zlib zlib zlib1g-dev zlib zlib-devel zlib-devel mingw-w64-x86_64-zlib
libSDL2 sdl2 libsdl2-dev sdl2 SDL2-devel libSDL2-devel mingw-w64-x86_64-SDL2
bzip2 bzip2 libbz2-dev bzip2 bzip2-devel libbz2-devel mingw-w64-x86_64-bzip2
libzstd zstd libzstd-dev zstd libzstd-devel libzstd-devel mingw-w64-x86_64-zstd
pkgconf pkg-config pkgconf pkgconf pkgconf pkgconf mingw-w64-x86_64-pkg-config
libpng libpng libpng-dev libpng libpng-devel libpng16-devel mingw-w64-x86_64-libpng
libfreetype freetype libfreetype6-dev freetype2 freetype-devel freetype2-devel mingw-w64-x86_64-freetype*
libminiupnpc miniupnpc libminiupnpc-dev miniupnpc miniupnpc-devel miniupnpc-devel mingw-w64-x86_64-miniupnpc*
libfluidsynth fluidsynth libfluidsynth-dev fluidsynth fluidsynth-devel fluidsynth-devel mingw-w64-x86_64-fluidsynth*
libSDL2_mixer sdl2_mixer libsdl2-mixer-dev sdl2_mixer SDL2_mixer-devel libSDL2_mixer-devel mingw-w64-x86_64-SDL2_mixer
libfontconfig fontconfig libfontconfig-dev fontconfig fontconfig-devel fontconfig-devel -

Libraries for Microsoft Visual Studio

Note: Simutrans Extended (without CMake) does not support using vcpkg. If you wish to compile without CMake, check this forum thread that explain in more detail how to set libraries for Simutrans Extended in MSVC.

  1. Download a git tool and clone https://github.com/Microsoft/vcpkg to an arbitrary directory that we will call vcpkg-root.
  2. Run bootstrap-vcpkg.bat
  3. Copy tools/install-building-libs-x64.bat to this folder and execute it, or install the libraries you want manually:
Copy to clipboard
./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).

Compiling

Go to the source code directory of simutrans (simutrans/trunk if you downloaded from svn). You have three build systems to choose from: make, MSVC, and CMake. We recommend make or MSVC for debug builds.

Compiling will give you only the executable, you still need a Simutrans installation to run the program. You can start simutrans with `-use_workdir` to point it to an existing installation.

Compiling with CMake

CMake makes easy to generate build files for various build systems, and the steps for doing so are pretty standard.

1. Generate build files

Options will be set automatically depending on the libraries found. You may want to set options manually when generating build files, for example the graphics backend (gdi, sdl2 or none) can be set with option -DSIMUTRANS_BACKEND=sdl2. For a list of options execute:

Copy to clipboard
cmake -LH .

Linux & MacOS

Change "Release" to "Debug" if you want a debug build.

Copy to clipboard
cmake -DCMAKE_BUILD_TYPE=Release -B build

MSYS MinGW

Change "Release" to "Debug" if you want a debug build.

Copy to clipboard
cmake -DCMAKE_BUILD_TYPE=Release -G "MSYS Makefiles" -B build

MSVC

For generating build files using the command line run the following. If you want a 32 bit executable change "x64" to "Win32"

Copy to clipboard
cmake.exe -B build -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.

2. Build Simutrans

The executable will be built in build/simutrans.

Linux /MinGW/MacOS

Copy to clipboard
cmake --build build -j cores

Replace "cores" with the number of cores in your procesor. You can find that number running the following command:

  • Linux: nproc
  • Mac: sysctl -n hw.logicalcpu

MSVC

With MSVC you need to set the build type at this step in the command line:

Copy to clipboard
cmake --build build --target install --config Release

If you are using the GUI, just select Compile.

Compiling with make

The executable will be built in build/default.

MacOS

Compiling with make on MacOS is currently not supported. Use CMake instead.

  1. Open a terminal and run autoreconf -ivf
  2. Now run ./configure
  3. Type make AV_FOUNDATION=1 -j $(sysctl -n hw.logicalcpu) to compile Simutrans*
  4. 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.

GCC Systems

  1. Open a terminal and run autoconf
  2. Now run ./configure
  3. Finally type make -j $(nproc) to compile Simutrans

Manual configuration with make

  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
    • 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-3 Up to 3, enable the debug build
MSG_LEVEL=1-4 Up to 4, message verbosity level
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
USE_FONTCONFIG = 1 Use libfontconfig for font autodetection


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.

Compiling with Microsoft Visual Studio

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: 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.

Cross-Compiling

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

Distribution

When you compile Simutrans you will only get the executable file. If you want a full distribution ready to play, follow the next steps.

(Windows only) Setting up NSIS

NSIS must be properly installed and configured to build the pakset installer with the following plugins:

  • https://nsis.sourceforge.io/Nsisunz_plug-in
  • https://nsis.sourceforge.io/Inetc_plug-in
  • https://nsis.sourceforge.io/ShellLink_plug-in
  • https://nsis.sourceforge.io/CabX_plug-in
  • https://nsis.sourceforge.io/UnTGZ_plug-in

MinGW

1. Install the package mingw-w64-x86_64-nsis
2. Unpack the unicode version of the plugins in "/msys64/mingw64/share/nsis/unicode"

MSVC

1. Download NSIS https://nsis.sourceforge.io/Download
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.

Prepare the distribution

This step will generate automatically a ready to play installation of Simutrans by doing the following:

  • Copy the contents of the simutrans directory into the executable location.
  • Update the language files with the latest translations.
  • In MacOS it will also generate an app bundle.
  • In Windows it will also build the pakset installer if NSIS is found.

Mingw/Linux/Mac

You can run ./distribute.sh which will give you a zip file that contains everything needed to run simutrans.

CMake

Run the build step with the "--target install" option to generate a ready to play installation in build/simutrans.

Contribute

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

Problems

  • Building from source on AMD64 Linux: http://forum.simutrans.com/index.php?topic=945.0

  1. Development Index
  2. Compiling Simutrans
Rate this page:

Contributors to this page: Roboron3042 , Frank , IgorEliezer and system .
Page last modified on Monday May 6, 2024 00:35:26 CEST by Roboron3042.
This content is licensed under the terms of the Copyright.
History Source Comments 1
Contributions by author Discuss

More content and functionality (left side)

....

Copyright
Impressum

Data protection

Search

System Menu

  • Home
  • Search
  • Contact Us
  • Stats
  • Categories
  • Tags
  • Wiki
    • Wiki Home
    • Last Changes
    • Rankings
    • List Pages
    • Sandbox
    • Structures
  • Articles
    • Articles Home
    • List Articles
    • Submit Article
    • View submissions
  • Forums
    • List Forums
  • Directory
    • Submit a new link
    • Browse Directory
  • File Galleries
    • List Galleries
  • Spreadsheets
    • List Sheets
  • Trackers
    • List Trackers
    • Offline mode
  • Surveys
    • List Surveys
    • Stats

Articles

  1. Simutrans 124.5
  2. Simutrans 124.4.1
  3. unofficial pak64.german 0.124.4.0.1
  4. Simutrans 124.4
  5. PAK128.German 2.4
  6. unofficial pak64.german 0.124.0.0.7
  7. unofficial pak64.german 0.124.0.0.6
  8. Simutrans 124.3.1
  9. unofficial pak64.german 0.124.0.0.5
  10. 2024 Simutrans Screenshot Contest

Latest Changes

  1. de_simuconf_tab_pakset
  2. Home
  3. en_Code_Overview_3_Ribis_and_Slopes
  4. en_Code_Overview_2_Ways
  5. en_Code_Overview_1_World
  6. Copyright
  7. en_Code_Overview_5_Vehicles_and_Convoys
  8. en_Code_Overview_7_Movement_of_Convoys
  9. en_Code_Overview_6_Schedules_and_Routes
  10. en_Code_Overview_4_Signs
...more

Online Users

1281 online users

Newest Forum Posts

  1. Aw: en_menuconf_tab: Wofür steht 'ribi'?
  2. en_menuconf_tab: Wofür steht 'ribi'?

BugTracker

  1. Signals waytype tram_track not correct work
  2. fehlerhafte Darstellung bei Untergrundstrom
  3. ungleiche Frachtverteilung an Ölborinseln
  4. Liste verfügbare Fahrzeuge
  5. Grafikfehler Bodentextur
  6. Linksklick in Haltliste
  7. blank menu show

Last wiki comments

  1. en_BuildAnAirport: "In Extended, they have to..."
  2. en_BuildAnAirport: "Is there any advice on how..."
  3. en_Simutrans_repo_deb: "When installing..."
  4. en_Simutrans_repo_deb: "Also with Linux Mint 21.1 -..."
  5. en_Simutrans_repo_deb: "After a while, I found..."
  6. en_Simutrans_repo_deb: "Hi, I tested the following..."
  7. de_VehicleDef: "Loading time ist ein..."
  8. de_tikiwiki_hilfe_index: "cialis normaldosis <a..."
  9. de_tikiwiki_hilfe_index: "cialis moment urban..."
  10. de_FactoryDef: "z.B. bei Ölbohrinseln mit..."

Site information, links, etc.