Building OpenRCT2 on Linux
OpenRCT2 can only be built on little-endian architectures for now.
This page tells you how to build the project. For instructions on how to get assets and run it check installation on Linux and macOS.
Required Packages (General)
To build natively on Linux, you will need a set of libraries set up. Since most distributions come with a package manager, we expect you to use that. Required libraries include:
||Only for UI client.|
||Can be disabled.|
||Can be disabled.|
||Only for UI client.|
||only if building with http support.|
||>= 1.0; Only if building with multiplayer support.|
||Commonly provided by Mesa or GPU vendors; only for UI client, can be disabled.|
||Unless scripting is disabled.|
Additionally, you can add support for Discord's Rich Presence API by cloning https://github.com/discordapp/discord-rpc into the root clone directory. Do note discord-rpc requires rapidjson, which don't bother fixing their bugs and you may need the hackish workaround: janisozaur/rapidjson/commit/20f8604ee6cd078c1cb2346148c69c0c2c160db2
APT (Debian, Ubuntu)
The exact package names will differ from distribution to distribution, but here's a short list of the common ones:
sudo apt-get install --no-install-recommends -y cmake libsdl2-dev libicu-dev \ gcc pkg-config libspeex-dev libspeexdsp-dev libcurl4-openssl-dev \ libcrypto++-dev libfontconfig1-dev libfreetype6-dev libpng-dev libssl-dev libzip-dev \ build-essential make duktape-dev nlohmann-json3-dev libbenchmark-dev
This listing should work on Debian and Ubuntu.
This solution is tested continuously with our own dockerfile.
sudo pacman -S sdl2 curl nlohmann-json speexdsp fontconfig libpng openssl libzip gcc gcc-libs icu duktape
Run the following for dependencies, then proceed with Linux build instructions.
sudo dnf install gcc gcc-c++ json-devel \ openssl-devel SDL2-devel libicu-devel \ speexdsp-devel libcurl-devel \ cmake fontconfig-devel freetype-devel \ libpng-devel libzip-devel mesa-libGL-devel \ duktape-devel
This section is outdated and needs an update to reflect we can now build for x86_64 and other little-endian platforms.
This install requires either plain
x86 system or
amd64 with multilib enabled.
x86 system, you just need to configure the sources with cmake (see below) and compile.
amd64 you first need to enable multilib and then add
abi_x86_32 to at least following libraries:
# cat /etc/portage/package.use/abi_x86_32 ## Please note that this library list may be incomplete due to USE flag differences dev-cpp/nlohmann_json abi_x86_32 media-libs/libsdl2 abi_x86_32 media-libs/sdl2-mixer abi_x86_32 media-libs/speex abi_x86_32 net-misc/curl abi_x86_32
Then you need to
emerge required libraries and in case portage gives shows some dependency issues, fix up the libraries with missing
abi_x86_32 flags by adding them to the list above.
sudo zypper in SDL2-devel fontconfig libzip5 libzip-devel libpng16-devel libicu-devel speexdsp-devel curl libcurl-devel nlohmann_json openssl openssl-devel glibc zlib cmake gcc gcc-c++ fontconfig-devel
Notes for Leap
Some old Leap versions use an old version of gcc by default, while OpenRCT2 needs gcc7 or later. You'll need to fix the symlinks for g++ and c++ to point to g++-7. Leap 15 uses gcc7 by default.
apk add git gcc g++ make cmake libzip-dev curl-dev nlohmann-json sdl2-dev fontconfig-dev fts-dev icu-dev duktape-dev speexdsp-dev
Install these dependencies then build as normal:
sudo eopkg install sdl2-devel curl-devel libspeex-devel fontconfig-devel libpng-devel openssl-devel libzip-devel libicu-devel mesalib-devel nlohmann-json
mkdir build && cd build cmake .. # Remember to set your build flags, e.g. -DCMAKE_BUILD_TYPE=RelWithDebInfo make
This will generate a
openrct2 binary in the
build directory. To run you have two options:
make install or running it locally.
make install will download required resources (json objects, title sequences) and installs openrct2 under
/usr/local by default, but
DESTDIR will be properly honoured (see below).
Running it from the build directory
Alternatively you can install the required resources manually so can launch openrct2 from the project directory.
You need a functional
data directory next to the current working directory when you start
An easy way to generate such a data directory is by leveraging
make install. Type the following in the
DESTDIR=. make install
Alternatively you can install these assets yourself. The following needs to satisfied:
$build/data/has to have contents of
$build/data/g2.datneeds to exist. Build it using
make g2and then copy it into
$build/data/objecthas to have the extracted contents from https://github.com/OpenRCT2/objects/releases
$build/data/titlehas to have extracted contents from https://github.com/OpenRCT2/title-sequences/releases
~/.config/OpenRCT2/ in its absence) has to have
game_path set to an RCT install.
openrct2 will ask you for this directory when it first starts.
Keep in mind you can symlink stuff and that filesystems are case sensitive!
Alternatively you can specify the data directory like this:
Just symlink the
data directory in the current
build directory, which is the easiest approach for development
ln -s ../data data
Building with clang works the same way as building with GCC, you just need to change the CXX environment variable. Keep in mind, that you need to have an empty build directory as cmake will not switch compilers after it has already generated a Makefile.
mkdir build && cd build export CXX=$(which clang++) # OpenRCT2 is purely a C++ project, there's no need to set CC cmake .. make
See the optimization note above.
You can switch from Make to Ninja, if you prefer:
mkdir build && cd build cmake .. -G Ninja # Any other arguments you want, for example -DCMAKE_BUILD_TYPE=RelWithDebInfo ninja # No need to specify parallel, it does that automatically DESTDIR=. ninja install
#6658 added support for discord-rpc, Discord's Rich Presence client library. It gets automatically picked up when cloned into the root of repository.
Docker is a nice way of doing things when you have problems installing all the dependencies or just want to test on clean system. Docker containers are ephemeral snapshots of a specified system (described via
Dockerfile), where you can run your commands.
Let's see example from our current
PARENT=`readlink -f ../` chmod a+rwx `pwd` chmod g+s `pwd` docker run -u travis -v $PARENT:/work/openrct2 -w /work/openrct2/build -i -t openrct2/openrct2:32bit-only bash -ec "cmake ../ $OPENRCT2_CMAKE_OPTS && make"
This runs the specified command (
bash -ec "cmake ../ $OPENRCT2_CMAKE_OPTS && make") interactively as a
travis user dockerfiles/32bit/Dockerfile#L7, having previously mounted your local (host's)
$PARENT as container's
/work/openrct2, and will use
/work/openrct2/build as cwd.
You may want to update mountpoints so you can reflect your local paths easily, especially when debugging.
Apart from contents of mounted volumes, all results of commands you executed in this container will be gone after it exits.
To build using mingw toolchain, you will need the toolchain itself, cmake and some basic system utilities you likely already have (bash, unzip, wget, sha256sum).
install.sh script should largely handle that case. Said script should also download latest version of zip including precompiled libraries we use in the project and copy extracted contents to places where you could expect to find them.
Keep in mind we have no capacity to test the script thoroughly and while some caution and code review has been applied, it's possible that the script doesn't work properly or even breaks things. We welcome any patch to solve these kinds of problems.
CMakeLists.txt file to see what options are there, but in most basic case you should be fine with just
export OPENRCT2_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" TARGET=windows
build.sh is roughly just a fancy wrapper for
cmake -DCMAKE_BUILD_TYPE=Debug $OPENRCT2_CMAKE_OPTS .. make
You can either use the script or invoke
To launch the game, you would simply start
openrct2.exe using wine or Windows.