Skip to content

Building OpenRCT2 on MSYS2 MinGW

pactonal edited this page Oct 12, 2023 · 10 revisions

Required Packages (General)

Required libraries include:

Package Note(s)
sdl2 Only for UI client.
freetype Can be disabled.
fontconfig Can be disabled.
libzip >= 1.0
libpng >= 1.2
speexdsp Only for UI client.
curl only if building with http support.
openssl >= 1.0; Only if building with multiplayer support.
icu >= 59.0
zlib
mesa Only for UI client, can be disabled.
cmake
nlohmann-json >= 3.6.0
duktape Unless scripting is disabled.
benchmark Optional.
innoextract Optional runtime dependency; used for GOG installer extraction during setup
libvorbis
libogg
flac

All required packages are compiled for use in a singular MSYSTEM each, see below for each MSYSTEM's copy of these packages.

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

MinGW64

pacman -S mingw-w64-x86_64-{SDL2,freetype,fontconfig,libzip,libpng,speexdsp,curl,openssl,icu,zlib,mesa,cmake,nlohmann-json,duktape,libvorbis,libogg,flac}

And optionally

pacman -S mingw-w64-x86_64-{benchmark,innoextract}

MinGW32

pacman -S mingw-w64-i686-{SDL2,freetype,fontconfig,libzip,libpng,speexdsp,curl,openssl,icu,zlib,mesa,cmake,nlohmann-json,duktape,libvorbis,libogg,flac}

And optionally

pacman -S mingw-w64-i686-{benchmark,innoextract}

UCRT64

pacman -S mingw-w64-ucrt-{SDL2,freetype,fontconfig,libzip,libpng,speexdsp,curl,openssl,icu,zlib,mesa,cmake,nlohmann-json,duktape,libvorbis,libogg,flac}

And optionally

pacman -S mingw-w64-ucrt-x86_64-{benchmark,innoextract}

Clang64

pacman -S mingw-w64-clang-{SDL2,freetype,fontconfig,libzip,libpng,speexdsp,curl,openssl,icu,zlib,mesa,cmake,nlohmann-json,duktape,libvorbis,libogg,flac}

And optionally

pacman -S mingw-w64-clang-{benchmark,innoextract}

Clang32

pacman -S mingw-w64-clang-i686-{SDL2,freetype,fontconfig,libzip,libpng,speexdsp,curl,openssl,icu,zlib,mesa,cmake,nlohmann-json,duktape,libvorbis,libogg,flac}

And optionally

pacman -S mingw-w64-clang-i686-{benchmark,innoextract}

Compiling

GCC Toolchain (mingw-x86_64, mingw-i686, and ucrt-x86_64)

MSYS2's default cmake configuration uses ninja, but also provides options the option to use GNU Make

mkdir build && cd build
cmake -G "MinGW Makefiles" .. # Remember to set your build flags, e.g. -DCMAKE_BUILD_TYPE=RelWithDebInfo, you must specify the generator if you want to use make and not ninja
mingw32-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

mingw32-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 openrct2.

An easy way to generate such a data directory is by leveraging make install. Type the following in the build directory:

DESTDIR=. make install

Alternatively you can install these assets yourself. The following needs to satisfied:

$XDG_CONFIG_HOME/OpenRCT2/ (or ~/.config/OpenRCT2/ in its absence) has to have config.ini with 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:

./openrct2 --openrct-data-path=../data

OR

Just symlink the data directory in the current build directory, which is the easiest approach for development

ln -s ../data data

Clang (clang-x86_64 and clang-i686)

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.

Ninja

If you prefer to use ninja just run cmake without the -G flag:

mkdir build && cd build
cmake .. # Any other arguments you want, for example -DCMAKE_BUILD_TYPE=RelWithDebInfo
ninja # No need to specify parallel, it does that automatically
DESTDIR=. ninja install

discord-rpc

#6658 added support for discord-rpc, Discord's Rich Presence client library. It gets automatically picked up when cloned into the root of repository.

That should work, but it might require a little debugging. This is still quite finicky at the end of the day.

Clone this wiki locally