Skip to content

Building

tsjost edited this page Mar 20, 2023 · 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 libavcodec-dev libavformat-dev libglm-dev libopenal-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev

Arch Linux

# pacman -S bullet glm ffmpeg 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-video/ffmpeg media-libs/libsdl2 dev-libs/boost

Fedora

# dnf install cmake libGL-devel openal-soft-devel ffmpeg-devel bullet-devel glm-devel SDL2-devel boost-devel

Other (conan)

Install conan (add --upgrade if conan has already been installed)

$ python -m pip install --user conan

Go to the openrw source directory and create a build directory

$ cd "$OPENRW_SRC" && mkdir build && cd build

Download all dependencies using conan

$ conan remote add bintray https://api.bintray.com/conan/bincrafters/public-conan
$ conan install .. -s arch=x86_64

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 MSYS2 MinGW shell and install the MinGW packages for the toolchain and the dependencies using the following command:

pacman -Syu
pacman -S mingw-w64-x86_64-gcc make mingw-w64-x86_64-openal mingw-w64-x86_64-bullet mingw-w64-x86_64-glm mingw-w64-x86_64-ffmpeg 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 mingw-w64-x86_64-cmake for 64-bit version or pacman -S mingw-w64-i686-cmake for 32-bit version 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 2017

OpenRW uses conan to support Microsoft Visual Studio.

  1. Download and install CMake. Add it to PATH.

  2. Download and install Python. Add it to PATH.

  3. Install conan (add --upgrade to update an existing conan installation):

python -m pip install --user conan

macOS

All regular toolchains are supported: Xcode toolchain, gcc and clang. Dependencies can be installed using packages from Homebrew:

brew install cmake bullet glm ffmpeg sdl2 boost

OpenBSD

Only tested on -current

pkg_add cmake ffmpeg 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.

If building failed as in https://github.com/rwengine/openrw/issues/739 you can try following commands after git clone.

cd ./openrw
git submodule init
git submodule update

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
cmake --build .

Some toolchains, such as Visual Studio and Xcode, require a configuration type while building:

cmake --build . --config Release

Using conan

mkdir build
cd build
conan install .. -s arch=x86_64 -s build_type=Release
cmake .. -DUSE_CONAN=ON -DCMAKE_BUILD_TYPE=Release
cmake --build .

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 2017

This expects python and cmake in your %PATH% or shell environment

  1. Open a terminal

  2. cd to the checked out openrw repository

  3. Assuming you want to create a Visual Studio Solution at %SOLPATH% (replace %SOLPATH% with an existing path), run

python scripts/conan/create_vs_solution.py -v 2017 -a x64 "%SOLPATH%"
  1. A Visual Studio 2017 project has been created at "%SOLPATH%"

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 (also requires the libqt5opengl5-dev package)
  • ENABLE_SANITIZERS — Enable selected sanitizers for easier debugging (available: address, undefined, leak, thread)
  • ENABLE_PROFILING — Enable profiling at localhost:1138. Browse to that url to see profiling statistics
  • TEST_COVERAGE — When using gcc or clang compiler, collect line/function/branch coverage. Run make lcov to generate a report.

To use these options, transform them into cmake command line arguments using the -D<variable-name>=<value> format. For example BUILD_TESTS becomes -DBUILD_TESTS=ON.

An up-to-date list of (most) configuration options can be found at https://github.com/rwengine/openrw/blob/master/cmake_options.cmake