Skip to content

[EN] How to build and setup on Linux

Priit Laes edited this page Nov 11, 2024 · 27 revisions

Table of Contents

  1. Preparation
    1.1. Installing dependencies
    1.2. Getting the source code
  2. Building
    2.1. Configuring
    2.2. Compiling
  3. Installing
    3.1. Building a package for Debian/Ubuntu
    3.2. Building a package for Fedora/CentOS
    3.3. Building a package for ArchLinux/Manjaro
    3.4. Community repositories
    3.5. Game resources
    3.6. Portable installation
  4. Possible issues
    4.1. The installed engine doesn't start
    4.2. Command not found
    4.3. Error while loading shared libraries
    4.4. Can't setup renderer
  5. Known bugs and errors
    5.1. Crash when approaching a character at the start of the game
    5.2. I have low FPS
    5.3. I can't compile OpenXRay: GCC version error
    5.4. The sound is poorly positioned
    5.5. I can't load saves made with the original S.T.A.L.K.E.R. - Clear Sky
    5.6. S.T.A.L.K.E.R.: Shadow of Chernobyl doesn't work
    5.7. The game starts in English, how do I switch the language?
    5.8. The game crashes with mods installed

Preparation

Currently only GCC8, GCC9 and GCC10 compilers are officially supported, but you may find instructions for building with other compilers in Configuring and I can't compile OpenXRay: GCC version error. Your system must also support OpenGL 4.1.

Installing dependencies

To install the required packages for building the engine, run:

  • For Debian/Ubuntu
sudo apt install git cmake make libglew-dev libopenal-dev libcrypto++-dev libogg-dev libtheora-dev libvorbis-dev libsdl2-dev liblzo2-dev libjpeg-dev libncurses5-dev gcc g++ dpkg-dev libmimalloc-dev
  • For Fedora/CentOS
sudo dnf install git cmake make gcc gcc-c++ glew-devel openal-devel cryptopp-devel libogg-devel libtheora-devel libvorbis-devel SDL2-devel lzo-devel libjpeg-turbo-devel
  • For ArchLinux/Manjaro
sudo pacman -S gcc git cmake make libglvnd libjpeg6-turbo ncurses glew sdl2 openal crypto++ libogg libtheora libvorbis lzo lzop libjpeg-turbo mimalloc
  • For Gentoo
sudo emerge --ask gcc git cmake make libglvnd libjpeg-turbo ncurses glew libsdl2 media-libs/openal crypto++ libogg libtheora libvorbis lzo lzop mimalloc

Getting the source code

To get the source code, run:

git clone https://github.com/OpenXRay/xray-16.git --recurse-submodules

Building

Configuring

Enter the repository clone and create a building directory there. The name of the directory doesn't matter, e.g. bin or build (bin will be used for the rest of this documentation to refer to this directory). An example for creating the directory and entering it for the terminal:

cd xray-16 && mkdir bin && cd bin

Once you're inside of bin, configure the project by running:

  • For Debian/Ubuntu
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_BINDIR=/usr/games
  • For Fedora/CentOS
cmake .. -DCMAKE_INSTALL_LIBDIR=lib64 -DCMAKE_INSTALL_PREFIX=/usr
  • For ArchLinux/Manjaro
cmake .. -DCMAKE_INSTALL_PREFIX=/usr

! If you plan to build a package, go to Installing now.

  • For a portable installation (Use these instructions if you don't want to install the engine system-wide)
cmake ..

Additional parameters that can be used for the setup

! Refer to the documentation of your distribution for more information

DCMAKE_BUILD_TYPE - Select what kind of build you want to do. The build type can have one of these values:

  • Release - Release optimisation (default, recommended for most players)
  • Debug - For engine debugging
  • Mixed - A mix somewhere between Release and Debug
  • RelWithDebInfo - Release optimisations with debugging symbols

DCMAKE_INSTALL_PREFIX - Install prefix, we recommend /usr (e.g. /usr/bin, /usr/lib, /usr/share, ...)

DCMAKE_INSTALL_LIBDIR - The directory where libraries will be installed. Default value is lib (relative to INSTALL_PREFIX). If required, you can set it to:

  • lib - Usable for most distributions (default)
  • lib64 - For distributions where 32-bit and 64-bit libraries are strictly separated (Fedora, CentOS, ...)

DCMAKE_INSTALL_BINDIR - The directory where executable files will be installed. Default value is bin (relative to INSTALL_PREFIX). If required, you can set it to:

  • games - Recommended for Ubuntu
  • games/bin - Recommended for Gentoo

DMEMORY_ALLOCATOR - Select the memory allocator the engine should use. The memory allocator can be one of these values:

  • mimalloc - Compiles & uses mimalloc (default)
  • standard - Uses the system's native malloc implementation

Notes

To use clang: Clang is not supported, but feel free to try it:

CC=clang CXX=clang++ cmake ..

To include all optimizations for your machine:

CFLAGS="-march=native" CXXFLAGS="-march=native" cmake ..

Compiling

To compile the engine, run:

make -jx

! x denoted the number of threads you want to assign to the compile process. For example, if you want to use 4 threads:

make -j4

To put the log and errors to different files:

make -jx >out.log 2>error.log

If the compilation completed without errors, you can continue with installing the engine!

Installing

! It's preferable to build a package for your distribution

If you can't / don't want to build a package for your distribution, you can do sudo make install to install everything to your installation prefix (by default /usr). To uninstall everything again, run sudo make uninstall.

Building a package for Debian/Ubuntu

A .deb package can be created to install the engine via dpkg. If you are an Ubuntu user, we recommend building the DEB package.

! To properly generate the dependency list for the deb package, the dpkg-dev package must be installed.

  • Build the DEB package via make by running: make package

  • Build the DEB package via checkinstall by running: sudo checkinstall -D and answering the on-screen questions.

Both options will result in a DEB package you can install via sudo dpkg -i *.deb.

Building a package for Fedora/CentOS

A .rpm package can be created to install the engine via rpm.

  • Build the RPM package by running: make package

This will result in an RPM package you can install via sudo rpm -i *.rpm.

Building a package for ArchLinux/Manjaro

The xray-16/ArchLinux directory contains a ready-made PKGBUILD for building a package on these distros.

  • Build the package by running: cd ../ArchLinux && makepkg

This will result in a package you can install via sudo pacman -U openxray-dev...x86_64.pkg.tar.xz.

Community repositories

The following is a list of community-created repositories for installing OpenXRay.

Ubuntu 18.04

Launchpad.net

To add the repository and install OpenXRay, run:

sudo add-apt-repository ppa:eagleivg/openxray
sudo apt update
# sudo apt install openxray?

ArchLinux/Manjaro

The AUR has ready-made packages for OpenXRay:

OpenSUSE

Build.opensuse.org

Install the package in one click or add the repository and install it the traditional way:

sudo zypper ar obs://games games
sudo zypper ref
sudo zypper in openxray

Gentoo

Portage Ebuild

Nixpkgs

The latest stable release can be installed via Nixpkgs on NixOS and any other Linux distribution with Nix installed.

nix-env -iA nixpkgs.openxray

Game resources

To start the game, you'll need the original resurces of a licensed copy of S.T.A.L.K.E.R. - Call of Pripyat and/or S.T.A.L.K.E.R. - Clear Sky.

You'll need these directories from your S.T.A.L.K.E.R. game distribution:

  • levels
  • localization
  • mp
  • patches
  • resources

Put them in this directory:

  • ~/.local/share/GSC Game World/S.T.A.L.K.E.R. - Call of Pripyat/ - For Call of Pripyat
  • ~/.local/share/GSC Game World/S.T.A.L.K.E.R. - Clear Sky/ - For Clear Sky

!!!Attention: These paths must be created by you first. Pay attention to the spaces, they'll need to be properly escaped. For example:

mkdir -p ~/.local/share/'GSC Game World'/'S.T.A.L.K.E.R. - Call of Pripyat'

Steam version If you have a digital copy of the game on Steam then the resources can be found in ~/.local/share/Steam/steamapps/common/Stalker... (the default Steam game installation directory on Linux).

To install the resources from Steam via steamcmd, run:

steamcmd "+@sSteamCmdForcePlatformType windows" +login <your_steam_username> \
    +force_install_dir ~/.local/share/GSC Game World/S.T.A.L.K.E.R. - Call of Pripyat/ +app_update 41700 +quit

! If you don't want to waste space by having multiple copies of the directories on your drive, then keep reading.

Physical / GOG version If you bought a physical copy of the game or a digital one on GOG, you can unpack the resources with the innoextract CLI tool. To install innoextract via your package manager, run:

  • Debian/Ubuntu - sudo apt install innoextract
  • Fedora - sudo dnf install innoextract (For GOG archives you'll also need unrar from rpmfusion-nonfree repository, as unrar-free from default Fedora repositories lacks support for password-protected and multi-part archives).
  • ArchLinux/Manjaro - sudo pacman -S innoextract
  • Nixpkgs - nix-env -iA nixpkgs.innoextract

To unpack the distribution's archives:

  1. Copy the contents of the CD to a directory, e.g. ~/CoP
  2. Open a terminal, navigate to the directory you copied the CD contents to and run: innoextract setup.exe -L

innoextract options:

  • -L - Put all file & directory names in lowercase
  • -d - Specify where the files will be extracted to, e.g. CoP_unpack
  • --gog - Use this if you're unpacking the GOG version
  1. Once the unpacking is done, you'll have an app or game directory with the required directories we mentioned earlier.

Unpacked СD version
CD

Unpacked GOG version
GOG

!!!Attention: The required directory names (levels, localization etc) MUST be lowercase (small letters). This is relevant for the GOG copy of the game.

If you don't want to use up any additional space on your drive and already have the game installed (on Steam or a Windows partition)

You can create symbolic links to the required directories instead of copying them. For example, with the Steam version:

STEAM_DIR=~/.local/share/Steam/steamapps/common/Stalker\ Call\ of\ Pripyat
XRAY_DIR=~/.local/share/GSC\ Game\ World/S.T.A.L.K.E.R.\ -\ Call\ of\ Pripyat
mkdir -p "$XRAY_DIR"
ln -s "$STEAM_DIR/levels" "$XRAY_DIR/levels"
ln -s "$STEAM_DIR/localization" "$XRAY_DIR/localization"
ln -s "$STEAM_DIR/mp" "$XRAY_DIR/mp"
ln -s "$STEAM_DIR/patches" "$XRAY_DIR/patches"
ln -s "$STEAM_DIR/resources" "$XRAY_DIR/resources"

Launching the game

S.T.A.L.K.E.R. - Call of Pripyat

  • Search & click S.T.A.L.K.E.R.: Call of Pripyat (OpenXRay) in your application menu or
  • Run xr_3da from a terminal

S.T.A.L.K.E.R. - Clear Sky

  • Search & click S.T.A.L.K.E.R.: Clear Sky (OpenXRay) in your application menu or
  • Run xr_3da -cs from a terminal

!!!Attention: S.T.A.L.K.E.R. - Clear Sky support is still incomplete. You may experience bugs and errors.

If the game resources are located in a different directory than what we recommend, use the -fsltx switch with the path to your fsgame.ltx:

xr_3da -fsltx /path/to/fsgame.ltx

NOTE: path to fsgame.ltx must be absolute, starting from the / (filesystem root).

If you want to debug the engine with gdb, run:

DEBUGGER="gdb --ex=r --args" xr_3da

Portable installation

If you can't and/or don't want to install OpenXRay system-wide (as a package or via make install), you can use this method:

  1. In your home directory, create a directory for the engine (e.g. S.T.A.L.K.E.R.) and for the game (e.g. S.T.A.L.K.E.R.CoP)
  2. Follow the steps outlined in Preparation and Building of this tutorial.
  3. After compiling, copy the contents of the xray-16/bin/<arch>/Release/ directory to ~/S.T.A.L.K.E.R./bin/. (<arch> depends on your CPU architecture, for example on a 64-bit Intel/AMD system replace <arch> with x64)
  4. Copy the gamedata directory and fsgame.ltx file from xray-16/res to ~/S.T.A.L.K.E.R./.
  5. Copy/Symlink the required directories (levels, localization etc) into ~/S.T.A.L.K.E.R.CoP/. It should look like this afterwards: S.T.A.L.K.E.R.CoP bin

To launch the game open a terminal, go to ~/S.T.A.L.K.E.R. and run:

./bin/xr_3da -fsltx ./fsgame.ltx

For S.T.A.L.K.E.R. - Clear Sky, use the -cs switch:

./bin/xr_3da -cs -fsltx ./fsgame.ltx

Possible issues

The installed engine doesn't start

Open a terminal and launch the game via xr_3da. You should get a more specific error message.

Command not found

bash: xr_3da: Command not found

The location of the executable could not be found. You may have used a bad value in the project setup step. As a rule, the default value for DCMAKE_INSTALL_PREFIX (/usr) and DCMAKE_INSTALL_BINDIR (<DCMAKE_INSTALL_PREFIX>/bin) should work on most systems. If your DCMAKE_INSTALL_BINDIR value does not appear in your PATH (echo $PATH), try using a full path to xr_3da (/path/to/xr_3da) or adding the path to your PATH environment variable.

Error while loading shared libraries

xr_3da: error while loading shared libraries: xrEngine.so: cannot open shared object file: No such file or directory

It's possible that the path you installed the libraries to (DCMAKE_INSTALL_LIBDIR) may not be on your system's LD_LIBRARY_PATH list (echo $LD_LIBRARY_PATH). Try using a path from that list (using DCMAKE_INSTALL_PREFIX and DCMAKE_INSTALL_LIBDIR) or add your preferred path to your LD_LIBRARY_PATH environment variable.

Can't setup renderer

FATAL ERROR
 
[error] Expression    : setupSelectedRenderer
[error] Function      : InitializeRenderers
[error] File          : /home/USERNAME/OpenXray/xray-16/src/xrEngine/EngineAPI.cpp
[error] Line          : 128
[error] Description   : Can't setup renderer

When using a portable installation, you may need to copy the shaders from the xray-16/res/gamedata/ directory into your game's resources directory:

.
├── bin/
├── gamedata/
├── levels/
├── localization/
├── mp/
├── patches/
├── resources/
└── fsgame.ltx

To launch the game open a terminal, go to ~/S.T.A.L.K.E.R./bin and run:

LD_LIBRARY_PATH="./bin:$LD_LIBRARY_PATH" ./bin/xr_3da -fsltx ./fsgame.ltx

Known bugs and errors

  1. When quitting the game, the process may hang indefinitely (as of May 2020, this problem has been observed when building with GCC9 or higher)
  2. Saves and logs do not support UTF-8
  3. On AMD GPUs, bugs may be encountered with SSAO enabled. We recommend turning this setting off on such systems.
  4. Save file previews do not get generated.

Crash when approaching a character at the start of the game

Such a crash is in most cases accompanied by an error log message similar to this:

[error] Expression  : !m_error_code
[error] Function    : ~raii_guard
[error] File        : /.../.../xray-16/src/xrSCRIPTENGINE/script_engine.cpp
[error] Line        : 569
[error] Description : ...R. -Call of Pripyat\gamedata\scripts\sound_theme.script:225: bad argument #1 to 'gsub' (string expected, got nil)

This problem has only been noticed with GOG copies of the game. To fix this issue:

  1. Go to the resource directory (~/.local/share/GSC Game World/S.T.A.L.K.E.R. - ...)
  2. Make sure the directory name of the localization directory is in lowercase letters Correct: localization _Incorrect: Localization
  3. The localization directory should contain the archives with the desired localization of the game. All other files and directories should be deleted.
  • English - base_sounds.db xefis_movies.db xenglish.db
  • French - base_sounds.db xefis_movies.db xfrench.db
  • German - base_sounds.db xger_movies.db xgerman.db
  • Italian - base_sounds.db xefis_movies.db xitalian.db
  • Polish - base_sounds.db xpolish_texts.db xrus_sounds.db xxpolish_sounds.db
  • Russian - base_sounds.db xefis_movies.db xrussian.db
  • Spanish - base_sounds.db xefis_movies.db xspanish.db

The files listed above can be found in localization/En, localization/Fr, localization/Ge etc. 4) In the settings file ~/.local/share/GSC Game World/S.T.A.L.K.E.R. - .../user.ltx, you should remove the g_launguage parameter or set it to one of the following values, depending on the language you chose:

  • English - g_language eng
  • French - g_language fra
  • German - g_language ger
  • Italian - g_language ita
  • Polish - g_language pol
  • Russian - g_language rus
  • Spanish - g_language spa

For example, to get the Russian version:

I have low FPS

The maximum values of some advanced graphics settings are significantly higher compared to the original game. Care should be taken with the following settings:

  • Object details - This option has a significant impact on performance.
  • Grass render distance - This option was not present in the original engine, it was a fixed value.
  • Grass density - The maximum value of this option was doubled / tripled compared to the original engine.
  • Shadow map quality - This option was not present in the original engine, it was a hidden value. The only way of changing it was via startup settings. However, even with the startup setting the maximum value was limited to 4096. This option has been increased to a maximum value of 16384.

I can't compile OpenXRay: GCC version error

Some distributions may not offer GCC version 8 or later by default. You may be able to manually install a later GCC version via your package manager. If you choose to do so, you may need to tell the project which compiler it should use:

cmake -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ..

We don't recommend it but if your distribution does not offer GCC version 8 or later, you can change the minimum GCC version in CMakeLists.txt. Look for CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0 and change it to a lower value, for example: CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.4.0. Please understand that we can not guarantee that this won't cause any problems, either with the compilation or the resulting engine build.

The sound is poorly positioned

HRTF must be forced on in OpenAL:

echo "hrtf = true" >> ~/.alsoftrc

If that didn't work, check if the default-44100.mhr and default-48000.mhr files are present. (On Ubuntu you may need to install the libopenal-data package)

If that didn't work either, launch the game with

ALSOFT_LOGLEVEL=3 ALSOFT_LOGFILE=/tmp/openallog.txt xr_3da

and look for HRTF in the log.

I can't load saves made with the original S.T.A.L.K.E.R. - Clear Sky

We don't offer backwards-compatibility with S.T.A.L.K.E.R. - Clear Sky's save file format.

S.T.A.L.K.E.R.: Shadow of Chernobyl doesn't work

Currently, we're still working on adding support for S.T.A.L.K.E.R.: Shadow of Chernobyl.

The game starts in English, how do I switch the language?

Follow the steps outlined in Crash when approaching a character at the start of the game.

The game crashes with mods installed

Unfortunately, compatibility with some mods is incomplete due to the following reasons:

  1. Many developers make their own changes to the engine. These changes may not exist in OpenXRay. Such mods are incompatible with OpenXRay. Even if the mod developer used OpenXRay, it's possible they may have made changes to their version of the engine.
  2. Mod developers often use different casing (uppercase vs lowercase) in paths and game resource filenames. The Linux filesystem differs from the Windows one: While Windows considers A.dds and a.dds filenames to be the same, in Linux they refer to different files. If such a case mismatch is present in the mod, you may get a crash due to a missing file.

For a mod to work with OpenXRay, it must fulfill the following requirements:

  1. The mod must not affect the engine itself.
  2. Paths and filenames in scripts must use the correct casing.
Clone this wiki locally