[Guide] libtrainsim on windows

In this guide I go through the steps required to get the libtrainsim refreence implementation working on windows. A full linux guide will follow soon.

First off you have to install msys2. You get it from its website: https://www.msys2.org/

After the installation is finished you have to download the setup scripts repository from the gitlab: https://git.thm.de/bahn-simulator/setup-scripts/
You can simply download the repository as zip and extract that to C:msys64homeUSERNAME.

Now open the mingw64 shell from the start menu. It might be helpful to pin that since you will have to start it more than once.

Now type the following command: bash setup-scripts/user/msys2_install_only.sh

If the shell closes simply reopen it and execute the command again. Using the up arrow you can execute a command again. This happens because windows does not allow a running application to be updated.

Once the installation is finished execute the following command: bash setup-scripts/user/mingw64_build.sh

This command will download the simulator source code and data. After that it will compile the code. Once the compilation is finished you can start using the simulator.

If you open the msys home in the explorer you will see that there is a new directory called simulator. While you can find the executable in the build directory, it is not possible to simply execute it (at least for now). You will have to start the simulator from the mingw64 terminal.

First navigate to the simulator directory by executing the following: cd simulator. Then you can start the simulator with the default Track data by typing the following: ./build/simulator.exe

As you can see this starts the simulator and you can control the acceleration using w and s. If you want to close the simulator click on the x in the top right corner or press Escape.

If you want to use other Tracks you can simply pass the path to a Track file as an argument to the simulator. The following command passes the example Track file: ./build/simulator.exe ./data/production_data/Track.json

That’s all you need to know to get the simulator running under windows.
Have a nice day and until next time.