Skip to content

Building

TheVice edited this page Sep 10, 2016 · 71 revisions

Introduction

  • This is a general guide on how to build OpenRW mostly aimed at beginners.
    • There are also other ways which are not described here.
  • Try to avoid using path-names which contain spaces as your toolchain or OpenRW may not be able to handle it.
  • Use forward slashes (/) instead of backward slashes (\) for path-names unless explicitly stated otherwise.
  • Text in angle brackets (< and >) should be replaced by you (also remove the brackets!).

Pre-steps

You usually have to install dependencies or set up your toolchain before you can start building OpenRW.

Linux

It is assumed that you have a toolchain installed (including git, gcc, cmake and all standard libraries)

Ubuntu

# apt install libbullet-dev libsdl2-dev libmad0-dev libglm-dev libsndfile-dev libopenal-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev

Arch Linux

# pacman -S bullet glm libmad libsndfile sdl2 boost

Note that there is an AUR package which is maintained by a community member.

Gentoo Linux

SDL2 has to be compiled with OpenGL support so add media-libs/libsdl2 opengl to /etc/portage/package.use.

# emerge -a sci-physics/bullet media-libs/glm media-libs/libmad media-libs/libsndfile media-libs/libsdl2 dev-libs/boost

Fedora

# dnf install openal-soft-devel bullet-devel glm-devel libmad-devel libsndfile-devel SDL2-devel boost-devel

Windows

MinGW / MSYS

If you don't have MSYS installed yet, download and install MSYS. Please do not include spaces in the MSYS install path.

Start a MSYS shell and install the MinGW packages for the toolchain and the dependencies using the following command:

pacman -Sy
pacman -S mingw-w64-x86_64-gcc make
pacman -S mingw-w64-x86_64-openal mingw-w64-x86_64-bullet mingw-w64-x86_64-glm mingw-w64-x86_64-libsndfile mingw-w64-x86_64-libmad mingw-w64-x86_64-SDL2 mingw-w64-x86_64-boost

Note that this installs the 64-Bit toolchain. If you want to produce 32-Bit code you should instead install packages starting with mingw-w64-i686- instead of mingw-w64-x86_64-

Next, type cmake to find out if you have an existing CMake installation. If you don't have it installed already (command not found), type pacman -S cmake to start the installation.

You can also install Git using pacman -S git if you don't have another Git installation and intend to use it.

You can close the MSYS shell now.

Microsoft Visual Studio 2015

It is recommended that you use the MinGW / MSYS toolchain on Windows instead, because it is easier to use.

  • Install CMake

    • You can download any Windows version here. If you use the graphical installer (.msi-File) you should choose one of the "Add CMake to the system PATH"-options for convenience. If you don't do this (or use the version without installer), you'll manually have to add CMake to the %PATH% variable if you intend to use the console version. Alternatively, you can use the graphical user-interface for CMake.
  • Install Boost

  • Download our OpenRW dependencies package (includes binaries for Bullet, OpenAL, SDL2, GLM)

    • Available as [32-Bit version] or [64-Bit version] FIXME: Not available yet
    • Extract the zip file after the download.
  • Install a Git client such as Git for Windows

macOS

Mac users should install Xcode and those packages from Homebrew:

brew install cmake bullet glm libsndfile mad sdl2

OpenBSD

Only tested on -current

pkg_add cmake libmad libsndfile glm bullet sdl2 gcc-4.9

On OpenBSD you will also need to tell openrw to build using egcc and eg++:

export CC=egcc CXX=eg++ 

Getting the source code

Git

Git is recommended if you also want to develop OpenRW.

git clone --recursive https://github.com/rwengine/openrw.git openrw

Note that you must use the recursive option to also clone the submodules.

Source Package

Alternatively, you can download the latest source code package.

Build

Most platforms

Open a shell in the OpenRW directory and type:

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Windows

MinGW / MSYS

Open a MinGW Shell (this is not the MSYS shell you've used to install MinGW!) in the OpenRW directory and type:

mkdir build
cd build
cmake .. -G"MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release
make

Microsoft Visual Studio 2015

Using the command window or a shell (recommended)

FIXME: This does not work yet!

This expects cmake in your %PATH% or shell environment

First, Set your shell path to the OpenRW folder using the cd command. Then run the following commands:

mkdir build
cd build
cmake .. -DRW_DEPENDENCIES="<path to the extracted OpenRW dependencies>" -DBOOST_ROOT="<path to your boost installation>" -DBOOST_LIBRARYDIR="<path to your boost installation>/lib64-msvc-14.0"

For 32-Bit replace the lib64-msvc- near the end by lib32-msvc-.

This will generate an OpenRW.sln in the build folder. Open it using Visual Studio and compile OpenRW by building the solution.

Alternatively, you can build the solution from the terminal, using:

cmake --build . --target Release

Using the CMake GUI

You have to do these one-time steps which are necessary to generate a Visual Studio 2015 project file:

  1. Start the CMake GUI.
  2. Click "Browse Source", select your OpenRW folder
  3. Click "Browse Build", create a new folder and select it
  4. Click on "Add Entry" and set Name: "RW_DEPENDENCIES", Type: "PATH", Value: "<path to the extracted OpenRW dependencies>"
  5. Click on "Add Entry" and set Name: "BOOST_ROOT", Type: "PATH", Value: "<path to your boost installation>"
  6. Click on "Add Entry" and set Name: "BOOST_LIBRARYDIR", Type: "PATH"
  • For 32-Bit, set Value: "<path to your boost installation>/lib32-msvc-14.0"
  • For 64-Bit, set Value: "<path to your boost installation>/lib64-msvc-14.0"
  1. Click on "Configure"
  • For 32-Bit, set "Visual Studio 14 2015" as Generator
  • For 64-Bit, set "Visual Studio 14 2015 Win64" as Generator
  1. Click on "Generate"

This will generate an OpenRW.sln in the build folder you've chosen in Step 2. Open it using Visual Studio and compile OpenRW by building the solution.

Additional CMake Build options

The default build configuration will only build rwgame. To build other components:

  • BUILD_TESTS — Build the test suite
  • BUILD_VIEWER — Build the Qt GUI for viewing data
Clone this wiki locally