Skip to content

10 Building on Linux

Shoegzer edited this page Jan 17, 2024 · 8 revisions

Introduction

This guide demonstrates how to build PCSX2 in Linux environments. Note that the steps provided below may vary depending on the distribution - such variances are not officially supported by the PCSX2 team.

Note that the procedure defined herein closely mirrors the scripts used by the PCSX2 CI process. These scripts provide more information behind the build process than what is stated here.

Dependencies

Note that dependencies tend to change over time, along with their required versions. In particular, PCSX2 no longer supports the gcc compiler, as it has transitioned to clang/llvm due to the many benefits the latter compiler offers, including superior efficiency and speed.

Build system

  • clang >= 17.0.6
  • cmake
  • git
  • lld >= 17.0.6
  • llvm >= 17.0.6
  • ninja

Libraries

  • libaio
  • libpng
  • libx11
  • qt >= 6.6.1
  • sdl2 >= 2.28.5
  • soundtouch
  • xz

Build procedure

Clone repository

git clone --recursive https://github.com/PCSX2/pcsx2.git
cd pcsx2

Prepare build with CMake

mkdir build
cd build
cmake -DCMAKE_C_COMPILER=<path_to_clang> -DCMAKE_CXX_COMPILER=<path_to_clang++> -DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld" -GNinja ..

Note the following optional CMake flags that are commonly used:

  • -DCMAKE_BUILD_TYPE=Release|Devel|Debug

    • Release: Fastest build, but lacks debug/crash information
    • Devel: Adds detailed trace logging abilities, but lacks debug/crash information
    • Debug: Slowest build as there are no compiler optimizations, but offers debug/crash information
  • -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

    • Uses ccache to speed up the build process
  • -DCMAKE_PREFIX_PATH=<path>

    • Defines paths to system libraries that are not globally recognized within the build environment. For example, if SDL2 is manually installed from a source outside its official repository, then its path can be defined here.

Execute build

ninja