PCSX2 Documentation/PCSX2 Build Scripts

From PCSX2 Wiki
Jump to navigation Jump to search

PCSX2 is an extremely complex project with many, many source code files, so much of the process of building and compiling the project is automated.

build.sh

This is where the fun begins. Running this shell script will begin the long build process for PCSX2. First, the script checks for arguments in the command line, setting the build and log directories. Then, the script runs CMake. You can view the available options with build.sh -help.

CMake

PCSX2 is a cross platform application, so there are some individuals who prefer using Windows development tools (Visual Studio) and some who prefer using Linux development tools (GNU Compiler Collection). It can become a headache trying to sync project files from all these different tools, so there is a program called CMake which can actually generate project and make files for all these different platforms.

The CMake build process is controlled by This file here. Cmake will check if directories exist for the different modules of pcsx2 (core, plugins, etc) and then search for CMakeLists.txt files within those directories, which in turn may check for further subdirectories. For example, the CMakeLists.txt file in the plugins folder will check if directories exist for the different pcsx2 plugins. There will in turn be a CMakeLists.txt file in each of the plugin folders. When you add a new source code file, you will need to add it to the CMakeLists.txt file for the module of pcsx2 you are working on.

CMake Build Parameters

Basic parameters:

  • Use Release/Devel/Debug : -DCMAKE_BUILD_TYPE=Release|Devel|Debug
    • Release: Best in speed, but provides little or no debug/crash info.
    • Devel: Adds detailed trace logging abilities, but still lacks debug/crash info.
    • Debug: No compiler optimizations. Very good for debug/crash info but also very slooowww.
  • Follow XDG standard: -DXDG_STD=TRUE
  • Build all plugins: -DEXTRA_PLUGINS=TRUE

Expert parameters

(not supported, the best is to use the default options)

  • Tune C flags : -DUSER_CMAKE_C_FLAGS:STRING="cflags"
  • Tune C++ flags : -DUSER_CMAKE_CXX_FLAGS:STRING="cxxflags"
  • Tune linker flags : -DUSER_CMAKE_LD_FLAGS:STRING="ldflags"

Expert debugging parameters

(typical developers-only option)

  • Build GS replayer: -DBUILD_REPLAY_LOADERS=TRUE
  • Use Address Sanitizer: -DUSE_ASAN=TRUE

Experimental parameters

(not supported, the best is to use the default options)

  • zzogl: Use GLSL for shading instead of nvidia cg : -DGLSL_API=TRUE
  • zzogl: Use EGL instead of GLX : -DEGL_API=TRUE
  • GSdx: Use openGL ES3.1 instead of pure openGL : -DGLES_API=TRUE
  • Use SDL2 (wxWidget must be linked with SDL1) : -DSL2_API=TRUE
  • Use GTK3 (wxWidget must be built with GTK3 support) : -DGTK3_API=TRUE
  • Use clang (nothing work) : -DUSE_CLANG=TRUE
  • 64 bits support (nothing work): -D64BIT_BUILD_DONT_WORK=TRUE

Expert options for package creation

  • Enable package mode : follow the FHS for distribution -DPACKAGE_MODE=TRUE
  • Plugin install path in package mode : -DPLUGIN_DIR="/usr/lib/pcsx2"
  • GameDB install path in package mode : -DGAMEINDEX_DIR="/usr/share/games/pcsx2"
  • GLSL shader install directory : -DGLSL_SHADER_DIR="/usr/share/games/pcsx2"
  • Update po (translation file) : -DCMAKE_BUILD_PO=TRUE
  • Rebuild shader : -DREBUILD_SHADER=TRUE
  • Disable AVX: -DDISABLE_ADVANCE_SIMD=TRUE
  • Enable/disable the stipping : -DCMAKE_BUILD_STRIP=TRUE|FALSE
    • TRUE: Remove debugging information.
    • FALSE: Keep symbols. Better for debug. (recommended since it should not have any impact on speed)

Running CMake to generate the makefile:

It is advised to use a build method that places build files outside the PCSX2 sources directory, as it makes it easier to delete all CMake build files:

$ mkdir build
$ cd build
$ cmake .. <other options>

Do the compilation:

$ make

Install files:

$ make install

Reporting Cmake bugs

Not all distributions and configurations were tested. In case you encounter a CMake bug that is really a CMake issue, you can report it. Please provide the following information:

  1. Linux distribution, the current kernel version, and architecture (32-bit or 64-bit)
  2. The CMake commands. For example: cmake CMakeLists.txt
  3. All of CMake's output. Something like this is good:
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found GTK2_GTK: /usr/lib/libgtk-x11-2.0.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/libX11.so
-- Found ALSA: /usr/lib/libasound.so
-- Found BZip2: /usr/lib/libbz2.so
-- Looking for BZ2_bzCompressInit in /usr/lib/libbz2.so
-- Looking for BZ2_bzCompressInit in /usr/lib/libbz2.so - found
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found wxWidgets: TRUE
-- Found ZLIB: /usr/lib/libz.so
-- Found Cg: /usr/lib/libCg.so;/usr/lib/libCgGL.so
-- Found PortAudio: /usr/lib/libportaudio.so
-- Found SoundTouch: /usr/lib/libSoundTouch.so
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/playstation/emulateur/package/pcsx2.snapshot-4810

Ubuntu PPA

With multiarch functionality, you can install a 32-bit PPA on a 64-bit Ubuntu. You need at least Ubuntu 12.04 (Precise) to do this.

Add the x86 architecture to your package manager (x64 installs of 12.04 or newer only)

In a terminal, type:

$ sudo dpkg --add-architecture i386

Add the multiverse package repository

Uncomment lines looking like this, where trusty is replaced by your Ubuntu version

deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

Add the PCSX2 PPA to your software sources

In a terminal, type:

sudo add-apt-repository ppa:gregory-hainaut/pcsx2.official.ppa
sudo apt-get update

Install the package on your system

sudo apt-get install pcsx2

Arch Linux

NOTE: for 64-bit architectures, multilib must be enabled in order to install PCSX2.

PCSX2 Stable

Open a terminal, and type:

$ sudo pacman -S pcsx2

PCSX2 Unstable

Add or uncomment the following lines in /etc/pacman.conf:

[Multilib]
Include = /etc/pacman.d/mirrorlist

Refresh package list:

# pacman -Sy

Download the tarball from the AUR package page, and unpack it. Open the folder that you just unpacked in a terminal, and type:

$ makepkg -csi

This will build the package, automatically installing all dependencies. It will then prompt for your password to install the package with pacman.