Back to blog home.

Mathias Gibbens
Hello, world!

Hello, world. Happy Saturday.

Posted
Mathias Gibbens
OpenRCT2 on Debian

One of my favorite PC games growing up was RollerCoaster Tycoon. The premise is pretty simple: complete scenarios where you build theme parks with cool roller coasters. RollerCoaster Tycoon 2 was released in 2002, and was a great gift that Christmas. Looking back, one of the most impressive things was that both games were written primarily in x86 assembler!

Then, in 2014 a project was started to reverse-engineer the code for RollerCoaster Tycoon 2, which would allow expansion of game capabilities and building on non 32bit Windows systems. This is the OpenRCT2 project. I found it in early 2015, and have been following it since. For quite a while now it's been possible to run OpenRCT on Windows, Linux, Mac, and Android platforms. In this post I share the steps required to build it on a Debian Buster system.

Prerequisites

  • A system running Debian Buster (or a Debian derivative)
  • A copy of the original game assets; you can get a copy of RollerCoaster Tycoon 2 from GOG.com, frequently on sale for 4-5 dollars
  • Basic familiarity with running commands in a Linux CLI

Compiling

I run Debian on my machines, due largely to the project's commitment to freedom as stated in the Debian Social Contract and stability of releases. Of course, stability means you don't always have the latest and greatest versions of software. As OpenRCT2 actively targets current standards and versions, occasionally this makes building on Debian stable challenging. However, as of this writing, Debian Buster has everything needed to build OpenRCT2:

apt install git cmake g++ pkg-config libssl-dev libcurl4-openssl-dev libfontconfig1-dev libjansson-dev libzip-dev libicu-dev libsdl2-dev libspeexdsp-dev
git clone https://github.com/OpenRCT2/OpenRCT2.git
cd OpenRCT2/
mkdir build
cd build/
cmake ..
make -j

Update 20200113 -- a fix was merged into develop that fixes the linking issue below, so you no longer need to modify the CMakeLists.txt file as mentioned below. Don't forget to run make g2!

Back in November 2019 a commit was pushed that causes builds on Debian Buster to fail:

Scanning dependencies of target openrct2-cli
[ 72%] Building CXX object CMakeFiles/openrct2-cli.dir/src/openrct2-cli/Cli.cpp.o
[ 73%] Linking CXX executable openrct2-cli
/usr/bin/ld: libopenrct2.a(Path.cpp.o): in function `std::filesystem::__cxx11::path::path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::filesystem::__cxx11::path::format)':
Path.cpp:(.text._ZNSt10filesystem7__cxx114pathC2EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS1_6formatE[_ZNSt10filesystem7__cxx114pathC5EONSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS1_6formatE]+0x4f): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
/usr/bin/ld: libopenrct2.a(Path.cpp.o): in function `std::filesystem::__cxx11::path::extension() const':
Path.cpp:(.text._ZNKSt10filesystem7__cxx114path9extensionEv[_ZNKSt10filesystem7__cxx114path9extensionEv]+0x19): undefined reference to `std::filesystem::__cxx11::path::_M_find_extension() const'
/usr/bin/ld: libopenrct2.a(Path.cpp.o): in function `std::filesystem::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::filesystem::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::filesystem::__cxx11::path::format)':
Path.cpp:(.text._ZNSt10filesystem7__cxx114pathC2INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE[_ZNSt10filesystem7__cxx114pathC5INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES1_EERKT_NS1_6formatE]+0x64): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/openrct2-cli.dir/build.make:88: openrct2-cli] Error 1
make[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/openrct2-cli.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I have a now closed issue on GitHub for tracking this bug. It essentially boils down to older versions of gcc requiring the linking of stdc++fs. There is an issue opened in upstream cmake that goes into further details and proposed solutions. For now, there's a very easy workaround for this issue:

# from the build directory
echo "target_link_libraries(libopenrct2 stdc++fs)" >> ../src/openrct2/CMakeLists.txt

Lastly, build a needed data file: make g2.

Final notes

After compiling, you can do a make install and enjoy creating your parks!

There is a debian/ subdirectory in the source that should make it very easy to build a proper Debian package, which may be useful if you'd like to copy the resulting build to another system. For purposes of this post, I've chosen to keep things simple and not go through the steps of building a package.

PS -- If you were a fan of Age of Empires II, there's a similar project that's still in an early state, but looks promising.

Mathias Gibbens
Video of the Week: Fire!

Remember, if this ever happens to you, just call 0118, 999, 88199, 9119, 725...3!

Posted