-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Building OpenRCT2 on macOS using CMake
To build natively on macOS, without using Xcode, you will need a set of libraries set up. This guide assumes you already have the following installed:
- A copy of the game files, downloaded onto your machine.
- OS X Developer Tools
- Homebrew / MacPorts / Fink
- Xcode (optional)
We'll install the libraries OpenRCT2 depends on through a package manager using the Terminal. We will be using Homebrew in the example below, but the equivalent command for MacPorts and Fink should look pretty similar.
brew install cmake duktape freetype icu4c libpng libzip nlohmann-json openssl pkg-config sdl2 speexdsp
Navigate to the directory OpenRCT2 is in (cd
), then make a build directory and invoke cmake
:
cd /path/to/repo/OpenRCT2
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=./install
make -j$(sysctl -n hw.logicalcpu) install # the install step builds openrct, g2 and downloads OpenRCT2 data
If any libraries are missing, you will see an error message. Adjust as needed or check out the Troubleshooting
section below.
Once all errors have been fixed we can start building:
make -j$(sysctl -n hw.logicalcpu) install
Now, before executing the game, link the just installed openrct2 data folder to the current directory to help openrct2
find it. Then run the game.
ln -s ./install/share/openrct2 data
./openrct2
The game will ask for the RCT2 installation path and will build object indices the first time it is started.
After the first install, you can build the openrct2
binaries, no install required:
make -j$(sysctl -n hw.logicalcpu)
Try out both solutions in problem 2
First check if you actually built openssl for both the i386 and x86_64 architectures by running the following command, replacing the openssl version with the version you installed:
file /usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dyl
This should output
/usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib: Mach-O universal binary with 2 architectures
/usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib (for architecture i386): Mach-O dynamically linked shared library i386
If only i386 or x86_64 are listed, then you will need to run brew reinstall openssl --universal
.
If you are sure the library is built for both architectures, it is possible that the build script is using OS X's version of openssl instead of the one installed by brew. To fix this run:
brew link --force openssl
Anything that needs to build against openssl will use brew's version now.
If you want to undo this in the future, you can always run brew unlink openssl
.
The reason this is happening is because pkg-config (run by cmake) is not finding a gl.pc
file.
To solve this we will create our own gl.pc file and tell pkg-config where to find it.
First create a pkgconfig folder in the directory where you cloned OpenRCT:
cd ..
mkdir pkgconfig
cd pkgconfig
Using your favourite editor, create a file called gl.pc
with the following content:
PACKAGE=GL
Name: OpenGL
Description: OpenGL
Version: 11.1.1
Cflags: -framework OpenGL -framework AGL
Libs: -Wl,-framework,OpenGL,-framework,AGL
Now tell pkg-config where to find this file and go back to the build directory:
export PKG_CONFIG_PATH=$(pwd):$PKG_CONFIG_PATH
cd ../build
You should find that cmake will now find the gl package.
It is possible that brew
was unable to create the relevant symlinks for SDL2 due to permissions problems. To fix this, do the following:
sudo chown root:wheel /usr/local/bin/brew
sudo brew link sdl2
If this doesn't work, chances are /usr/local/lib
isn't in your LIBRARY_PATH
. To fix this, add the following line to your ~/.bash_profile
and then restart the Terminal.
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
If your brew-installed ICU package cannot be found by cmake, it probably hasn't been linked to a common location. To work around this, invoke:
export CMAKE_PREFIX_PATH=/usr/local/opt/icu4c
cmake ..
Fire up the binary or application you just built. You should be good to go!
That's it! If you run into problems please paste all of the information you have into a GitHub issue and we'll take a look.
- Home
- FAQ & Common Issues
- Roadmap
- Installation
- Building
- Features
- Development
- Benchmarking & stress testing OpenRCT2
- Coding Style
- Commit Messages
- Data Structures
- CSS1.DAT
- Custom Music and Ride Music Objects
- Game Actions
- G1 Elements Layout
- game.cfg structure
- Maps
- Music Cleanup
- Objects
- Official extended scenery set
- Peep AI
- Peep Sprite Type
- RCT1 ride and vehicle types and their RCT2 equivalents
- RCT12_MAX_SOMETHING versus MAX_SOMETHING
- Ride rating calculation
- SV6 Ride Structure
- Settings in config.ini
- Sizes and angles in the game world
- Sprite List csg1.dat
- Sprite List g1.dat
- Strings used in RCT1
- Strings used in the game
- TD6 format
- Terminology
- Track Data
- Track Designs
- Track drawers, RTDs and vehicle types
- Track types
- Vehicle Sprite Layout
- Widget colours
- Debugging OpenRCT2 on macOS
- OpenGL renderer
- Overall program structure
- Rebase and Sync fork with OpenRCT2
- Release Checklist
- Replay System
- Using minidumps from crash reports
- Using Track Block Get Previous
- History
- Testing