This guide covers building OpenRCT2 from source on Windows using MSYS2 and the MinGW-w64 compiler. MSYS2 provides a Unix-like environment on Windows with easy package management.
Prerequisites
Installing MSYS2
Run the installer
Install to the default location: C:\msys64
Update package database
Launch “MSYS2 MSYS” from the Start Menu and run:If prompted to close the terminal, do so and reopen it, then run:
MSYS2 Environments
MSYS2 provides different environments:
- MSYS: Unix-like tools (don’t use for building OpenRCT2)
- MINGW64: 64-bit Windows applications (recommended)
- MINGW32: 32-bit Windows applications
- UCRT64: 64-bit with Universal CRT (alternative to MINGW64)
Use “MSYS2 MINGW64” terminal for building 64-bit OpenRCT2.
Installing Dependencies
Open “MSYS2 MINGW64” terminal and install build tools and dependencies:
For 64-bit build (MINGW64)
pacman -S --needed \
git \
mingw-w64-x86_64-toolchain \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-pkg-config
pacman -S --needed \
mingw-w64-x86_64-SDL2 \
mingw-w64-x86_64-libpng \
mingw-w64-x86_64-libzip \
mingw-w64-x86_64-zlib \
mingw-w64-x86_64-openssl \
mingw-w64-x86_64-curl \
mingw-w64-x86_64-freetype \
mingw-w64-x86_64-fontconfig \
mingw-w64-x86_64-icu \
mingw-w64-x86_64-zstd
# Optional dependencies
pacman -S --needed \
mingw-w64-x86_64-flac \
mingw-w64-x86_64-libvorbis \
mingw-w64-x86_64-libogg \
mingw-w64-x86_64-ccache
For 32-bit build (MINGW32)
Open “MSYS2 MINGW32” terminal:
pacman -S --needed \
git \
mingw-w64-i686-toolchain \
mingw-w64-i686-cmake \
mingw-w64-i686-ninja \
mingw-w64-i686-pkg-config
pacman -S --needed \
mingw-w64-i686-SDL2 \
mingw-w64-i686-libpng \
mingw-w64-i686-libzip \
mingw-w64-i686-zlib \
mingw-w64-i686-openssl \
mingw-w64-i686-curl \
mingw-w64-i686-freetype \
mingw-w64-i686-fontconfig \
mingw-w64-i686-icu \
mingw-w64-i686-zstd
Building OpenRCT2
Clone the repository
In the MSYS2 MINGW64 terminal:git clone https://github.com/OpenRCT2/OpenRCT2.git
cd OpenRCT2
The MSYS2 home directory is at C:\msys64\home\YourUsername\
Create a build directory
Do not build in the source directory. CMake will reject in-source builds.
Configure the build
For a release build:cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
For a debug build:cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug
Compile
This compiles openrct2.exe and openrct2-cli.exe along with required asset files. Locate binaries
Built executables are in the build directory:ls -lh openrct2.exe openrct2-cli.exe
Running OpenRCT2
From MSYS2 Terminal
From Windows
You can run the executable from Windows Explorer, but you need to ensure the MinGW DLLs are accessible.
Option 1: Add MinGW to PATH
Add to Windows PATH (requires restart or new terminal):
Option 2: Copy DLLs to build directory
# From MSYS2 terminal
cp /mingw64/bin/SDL2.dll .
cp /mingw64/bin/libpng16-16.dll .
cp /mingw64/bin/zlib1.dll .
cp /mingw64/bin/libzip-5.dll .
cp /mingw64/bin/libssl-*.dll .
cp /mingw64/bin/libcrypto-*.dll .
cp /mingw64/bin/libcurl-4.dll .
cp /mingw64/bin/libfreetype-6.dll .
cp /mingw64/bin/libstdc++-6.dll .
cp /mingw64/bin/libgcc_s_seh-1.dll .
cp /mingw64/bin/libwinpthread-1.dll .
cp /mingw64/bin/libicu*.dll .
cp /mingw64/bin/libzstd.dll .
# Add other dependencies as needed
Option 3: Create a portable package
Use the provided script:
# From repository root
./scripts/build-portable
This creates a portable distribution with all necessary DLLs.
Build Options
Portable Build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DPORTABLE=ON
Headless Server Build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DDISABLE_GUI=ON
Static Build
For a build with fewer DLL dependencies:
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DSTATIC=ON
Fully static builds are difficult on Windows. Some DLLs may still be required.
Building with Tests
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_TESTS=ON
ninja
# Run tests
ctest --output-on-failure
Disabling Features
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DDISABLE_OPENGL=ON \
-DDISABLE_FLAC=ON \
-DDISABLE_VORBIS=ON
Using CCache
CCache speeds up recompilation:
pacman -S mingw-w64-x86_64-ccache
CMake will automatically detect and use it. To disable:
cmake .. -G Ninja -DOPENRCT2_USE_CCACHE=OFF
Accessing Windows Files
Windows drives are available in MSYS2:
# Access C: drive
cd /c/Users/YourUsername/Documents
# Access D: drive
cd /d/Games
Troubleshooting
Wrong terminal environment
Always use “MSYS2 MINGW64” (for 64-bit) or “MSYS2 MINGW32” (for 32-bit), not “MSYS2 MSYS”.
Verify your environment:
echo $MSYSTEM
# Should output: MINGW64 or MINGW32
CMake not found
If CMake is not found:
# Ensure you installed the mingw version, not msys version
pacman -S mingw-w64-x86_64-cmake
# Check it's in PATH
which cmake
# Should be: /mingw64/bin/cmake
Compiler not found
# Install the toolchain
pacman -S mingw-w64-x86_64-toolchain
# Verify
which gcc
# Should be: /mingw64/bin/gcc
Missing pkg-config files
If CMake cannot find libraries:
# Check pkg-config paths
pkg-config --variable pc_path pkg-config
# Verify packages are installed
pkg-config --list-all | grep -i sdl2
DLL not found when running
If you get missing DLL errors:
# Use ldd to find missing DLLs
ldd openrct2.exe | grep "not found"
# Copy missing DLLs from /mingw64/bin/
cp /mingw64/bin/missing-dll.dll .
Or add /mingw64/bin to Windows PATH.
Building in-source error
rm -rf CMakeCache.txt CMakeFiles/
mkdir build
cd build
cmake ..
Stack protector issues
If you encounter linking errors related to stack protector:
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-fno-stack-protector"
Slow builds
Enable parallel builds (Ninja does this by default):
Install CCache:
pacman -S mingw-w64-x86_64-ccache
Advantages of MSYS2
- Easy dependency management: Single
pacman command
- Fast builds: Native MinGW compiler
- Unix-like tools: bash, grep, sed, etc.
- Package updates: Regular updates through pacman
- Cross-compilation: Can target both 32-bit and 64-bit
Comparing Build Methods
| Feature | MSYS2 | Visual Studio | WSL |
|---|
| Setup difficulty | Easy | Moderate | Easy |
| Dependencies | pacman | vcpkg | apt |
| Build speed | Fast | Moderate | Fast |
| Debugging | GDB | Best (VS) | GDB |
| Windows integration | Good | Best | Moderate |
| File size | Smaller | Larger | N/A |
Creating a Distribution Package
To create a distributable package:
Build in Release mode
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja
Use the build-portable script
cd ..
./scripts/build-portable
This creates a portable build with all DLLs in the bin/ directory.Test the portable build
Copy the bin/ directory to another location or computer and verify it runs.
Updating MSYS2 Packages
Keep your build environment updated:
# Update package database and installed packages
pacman -Syu
After major updates, you may need to rebuild:
cd build
rm -rf *
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
ninja
Next Steps