Compile (OS X)

chilledfrogs edited this page Sep 7, 2016 · 15 revisions

Table of Contents

Build script to automatize building process

There is an ongoing effort to create a shell script which fully automatizes the process of building RoR on OS X so even someone with no knowledge of coding could build RoR easily. The script is not finished yet and contributions are greatly appreciated. You can find the script on GitHub:
https://github.com/Hiradur/rigsofrods-osxscripts

Status: Most dependencies are set up correctly.

Overview

Note: These instructions do not make a completely working, finished product and need an experienced Mac user to improve and work on.

Rigs of Rods is a complex beast. It has a 3D engine, physics simulator, water and sky plug-ins, input device system, networking, localization plug-in module... and so on.

Rigs of Rods is built in 4 steps:

  • Download source code of RoR and its dependencies
  • Compile dependencies
  • Generate a Makefile with CMake for RoR
  • Use make to build RoR

Prerequites

To compile RoR you will have to work with the Terminal (Applications -> Utilities -> Terminal).

You need the Xcode Command Line Tools

xcode-select --install

You need the Homebrew package manager to install some dependencies. See http://brew.sh for info. You should install without sudo to minimize risk of damaging your system; Homebrew handles permissions by itself already.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once Homebrew is installed install these packages:

brew install wget pkgconfig cmake wxwidgets mercurial

Manual patch for minor code edits

Here's a patch fixing most compile errors: https://gist.github.com/chilledfrogs/a98f9457f81163f0e90c86f72d1dc60a

Manual linking fixes coming soon...

Additional dependencies not found in brew repositories

You have to compile a number of additional dependencies first to be able to compile RoR. Except for OGRE and MyGUI none of these are required to build RoR but highly recommended (or else you will lack vegetation, dynamic sky, multiplayer and scripting).

OGRE

From now on the environment variables "ROR_INSTALL_DIR" and "ROR_SOURCE_DIR" have always to be set. Use the following commands every time you open a new terminal session or save them to your .bashrc so they are saved permanently.

export ROR_SOURCE_DIR="$HOME/rigs-of-rods/source"
export ROR_INSTALL_DIR="$HOME/rigs-of-rods/install"

OGRE dependencies

cd "$ROR_SOURCE_DIR"
wget -c -O ogredeps.zip https://bitbucket.org/cabalistic/ogredeps/get/tip.zip
unzip -o ogredeps.zip
cd cabalistic-ogredeps-*
remove OSX_DEPLOYMENT_TARGET so we can build with libc++ (requires 10.7+)
sed -i .orig 's/set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)//g' CMakeLists.txt
cmake -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_INSTALL_PREFIX=$ROR_INSTALL_DIR
make -j2
make install

OGRE itself

cd $ROR_SOURCE_DIR
hg clone https://bitbucket.org/sinbad/ogre -b v1-9
cd ogre

cmake -DCMAKE_INSTALL_PREFIX=~/rigs-of-rods/install/ -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOGRE_BUILD_RENDERSYSTEM_GL3PLUS=OFF -DOGRE_BUILD_SAMPLES:BOOL=OFF -DOGRE_USE_BOOST=OFF
make -j2
make install

IMPORTANT: After this step the environment variable "PKG_CONFIG_PATH" has always to be set, otherwise CMake will not be able to find OGRE. Do this now and every time you open a new Terminal (setting it as $HOME is important, it didn't like the ~ shortcut last time I tried to do it):

export PKG_CONFIG_PATH=$HOME/rigs-of-rods/install/lib/pkgconfig

MyGUI

cd "$ROR_SOURCE_DIR"
git clone --depth 1 https://github.com/MyGUI/mygui.git
cd mygui

cmake -DCMAKE_INSTALL_PREFIX=~/rigs-of-rods/install/ -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE:STRING=Release -DMYGUI_BUILD_DEMOS:BOOL=OFF -DMYGUI_BUILD_DOCS:BOOL=OFF -DMYGUI_BUILD_TEST_APP:BOOL=OFF -DMYGUI_BUILD_TOOLS:BOOL=OFF -DMYGUI_BUILD_PLUGINS:BOOL=OFF -DMYGUI_RENDERSYSTEM=3
make -j2
make install

OGRE Paged Geometry

For the time being didn't try to build with, so mileage may vary

cd "$ROR_SOURCE_DIR"
git clone --depth 1 https://github.com/RigsOfRods/ogre-pagedgeometry
cd ogre-pagedgeometry
git pull
cmake -DCMAKE_INSTALL_PREFIX="$ROR_INSTALL_DIR" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -std=c++11" \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DPAGEDGEOMETRY_BUILD_SAMPLES:BOOL=OFF .
make -j2
make install

Caelum

For the time being didn't try to build with, so mileage may vary

cd "$ROR_SOURCE_DIR"
git clone --depth 1 https://github.com/RigsOfRods/ogre-caelum
cd ogre-caelum
git pull
cmake -DCMAKE_INSTALL_PREFIX="$ROR_INSTALL_DIR" \
-DCMAKE_CXX_FLAGS="-stdlib=libc++ -std=c++11" \
-DCaelum_BUILD_SAMPLES:BOOL=OFF .
make -j2
make install
important step, so the plugin can load:
ln -sf "$ROR_INSTALL_DIR/lib/libCaelum.so" "~/rigs-of-rods/install/lib/OGRE/"

SocketW

For the time being didn't try to build with, so mileage may vary

cd "$ROR_SOURCE_DIR"
git clone --depth 1 https://github.com/RigsOfRods/socketw
cd mysocketw
git pull
sed -i '/^PREFIX *=/d' Makefile.conf
make CFLAGS="-stdlib=libc++ -std=c++11" CXXFLAGS="-stdlib=libc++ -std=c++11" -j2 dylib
PREFIX="$ROR_INSTALL_DIR" make installosx

AngelScript

For the time being didn't try to build with, so mileage may vary

cd "$ROR_SOURCE_DIR"
mkdir angelscript
cd angelscript
wget -c http://www.angelcode.com/angelscript/sdk/files/angelscript_2.22.1.zip
unzip -o angelscript_*.zip
cd sdk/angelscript/projects/gnuc macosx
sed -i '/^LOCAL *=/d' makefile
make fails when making the symbolic link, this removes the existing versions
rm -f ../../lib/*
make CFLAGS="-stdlib=libc++ -std=c++11" CXXFLAGS="-stdlib=libc++ -std=c++11" -j2
rm -f ../../lib/*
LOCAL="$ROR_INSTALL_DIR" make -s install

Rigs of Rods

In $ROR_SOURCE_DIR/source/rigs-of-rods/source/main/CMakeLists.txt comment out (#) the line with USE_MUMBLE, since librt doesn't exist on Mac OS X; I will look for a solution since Mumble *with positional audio* is freely available for Mac OS X...

cd "$ROR_SOURCE_DIR"
git clone https://github.com/RigsOfRods/rigs-of-rods.git
cd rigs-of-rods
git pull
cmake -DCMAKE_INSTALL_PREFIX=~/rigs-of-rods/install/ -DROR_BUILD_CONFIGURATOR=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="-pipe -march=native -stdlib=libc++ -std=c++11"
make -j2
sed -i .orig '/^PluginFolder=/d' bin/plugins.cfg
echo "PluginFolder=$ROR_INSTALL_DIR/lib/OGRE" >> bin/plugins.cfg
cp -R bin "$ROR_INSTALL_DIR/"

If your build was successful you will find the binaries to start the game in ~/rigs-of-rods/install/bin/