PCSX2 Documentation/Compiling on Linux: Difference between revisions

From PCSX2 Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
==Introduction==
The following is a guide on how to obtain and compile the PCSX2 source code on the Linux platform.


This is a guide on how to install and compile the lastest PCSX2 source code on linux.
==Obtaining the Source Code==


==CMake Build System==
PCSX2 is hosted on GitHub, a website where people can contribute to each others' programming projects using the Git version control software. GitHub is essentially just a showcase for your projects, to actually work on them you need to download and install Git itself.


===Debian/Ubuntu build dependencies===
'''Arch Linux:''' <code># pacman -S git</code>


====Build system====
Next you are going to want to create a directory on your machine for the PCSX2 code to live in. For this example, let's say the directory you create is /home/you/workspace. You are going to want clone the remote PCSX2 repository like so:
<code>gcc</code>, <code>gcc-multilib</code>, <code>g++</code>, <code>g++-multilib</code>, <code>cmake</code>


====32-bit libraries on x86_64====
<code>$ cd /home/you/workspace</code><br />
<code>libaio-dev:i386</code>, <code>libbz2-dev:i386</code>, <code>libcggl:i386</code>, <code>libegl1-mesa-dev:i386</code>, <code>libglew-dev:i386</code>, <code>libgles2-mesa-dev</code>, <code>libgtk2.0-dev:i386</code>, <code>libjpeg-dev:i386</code>, <code>libsdl1.2-dev:i386</code>, <code>libsoundtouch-dev:i386</code>, <code>libsparsehash-dev</code>, <code>libwxgtk2.8-dev:i386</code>, <code>nvidia-cg-toolkit</code>, <code>portaudio19-dev:i386</code>, <code>zlib1g-dev:i386</code>
<code>$ git clone https://github.com/PCSX2/pcsx2.git</code>


===Arch Linux build dependencies===
You are now making a copy of the remote repository into your own directory.


Some of the required packages to build PCSX2 are available only in the [AUR](https://aur.archlinux.org), so the use of an [AUR helper](https://wiki.archlinux.org/index.php/AUR_Helpers) (ex: yaourt) is highly advised!
==Installing the Build System==


====Build system====
PCSX2 uses the cmake build system to create project files and other things for multiple platforms, and GCC to compile on the linux platform. To install these you are going to want to run:
<code>gcc</code>, <code>gcc-multilib</code>, <code>cmake</code>


====32-bit libraries====
'''Arch 64:''' <code># pacman -S cmake gcc-multilib </code>
Add or uncomment the following lines in <code>/etc/pacman.conf</code>:


<nowiki>
==Installing the Dependencies==
[Multilib]
Include = /etc/pacman.d/mirrorlist</nowiki>


Refresh package list:
PCSX2 relies on a number of 3rd party software libraries, so you are going to need to obtain those before you can compile the source code.


<nowiki>
'''Arch 64:''' <code># pacman -S lib32-alsa-lib lib32-bzip2 lib32-libjpeg lib32-glew lib32-nvidia-cg-toolkit lib32-portaudio lib32-sdl lib32-libaio lib32-wxgtk2.8 lib32-soundtouch sparsehash</code>
pacman -Sy lib32-libaio lib32-libcanberra lib32-libjpeg-turbo lib32-glew lib32-nvidia-cg-toolkit lib32-portaudio lib32-soundtouch lib32-wxgtk2.8 </nowiki>


===Using CMake===
==Compiling the Source==


====Basic mode: straightforward compilation====
Note: On Arch Linux, you will need to explicitly specify to cmake where to find the config executables. You can do that by adding these flags into the build script:
Run the <code>build.sh</code> script.
You can view the available options with <code>build.sh -help</code>


====Expert mode: CMake build parameters====
<code>-DwxWidgets_CONFIG_EXECUTABLE='/usr/bin/wx-config32-2.8'</code>
Basic parameters:
<code>-DwxWidgets_wxrc_EXECUTABLE='/usr/bin/wxrc32-2.8'</code>
*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):
Now that we have installed all external libraries, it is time to compile the source code! To do that, we are going to run a shell script which automates the entire process.<br />
*Tune C flags : `-DUSER_CMAKE_C_FLAGS:STRING="cflags"`
<code>$ cd /home/you/workspace/pcsx2</code><br />
*Tune C++ flags : `-DUSER_CMAKE_CXX_FLAGS:STRING="cxxflags"`
<code>$ sh build.sh</code>
*Tune linker flags : `-DUSER_CMAKE_LD_FLAGS:STRING="ldflags"`


Expert debugging parameters (typical developper only option):
==Running the Binary==
*Build GS replayer: `-DBUILD_REPLAY_LOADERS=TRUE`
*Use Address Sanitizer: `-DUSE_ASAN=TRUE`
*Force wxWidget 2.8 (to spot a regression) : `-DWX28_API=TRUE`


Experimental parameters (not supported, the best is to use the default options):
This process may take several minutes. Once it has finished, you should be able to run the pcsx2 binary:<br />
*zzogl: Use GLSL for shading instead of nvidia cg : `-DGLSL_API=TRUE`
<code>$ ./bin/pcsx2-dev<br />
*zzogl: Use EGL instead of GLX : `-DEGL_API=TRUE`
*GSdx: Use openGL ES3.1 instead of pure openGL : `-DGLES_API=TRUE`
*Use clang (nothing work) : `-DUSE_CLANG=TRUE`
*64 bits support (nothing work): `-D64BIT_BUILD_DONT_WORK=TRUE`


*Use SDL2 (wxWidget must be linked with SDL1) : `-DSL2_API=TRUE`
==Additional external links==
*Use GTK3 (wxWidget must be built with GTK3 support) : `-DGTK3_API=TRUE`
* [http://forums.pcsx2.net/Thread-PCSX2-for-Debian-Ubuntu PCSX2 for Debian/Ubuntu]
Expert options for package creation
* [http://www.noobslab.com/2013/01/install-ps2-emulator-in-ubuntu.html A guide on how to setup PCSX2 in Ubuntu]
*Enable package mode : follow the FHS for distribution `-DPACKAGE_MODE=TRUE`
* [http://forums.pcsx2.net/Thread-PCSX2-for-Archlinux PCSX2 for Archlinux]
*Plugin install path in package mode : `-DPLUGIN_DIR="/usr/lib/pcsx2"`
* [http://forums.pcsx2.net/Thread-PCSX2-for-Fedora PCSX2 for Fedora]
*GameDB install path in package mode : `-DGAMEINDEX_DIR="/usr/share/games/pcsx2"`
* [http://forums.pcsx2.net/Thread-PCSX2-for-Gentoo PCSX2 for Gentoo]
*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`
**<code>TRUE</code>: Remove debugging information.
**<code>FALSE</code>: Keep symbols. Better for debug. (recommended since it should not have any impact on speed)


===Running CMake to generate the makefile:===
[[Category:Guides]]
 
{{General articles}}
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:====
<code>make</code>
 
====Install files:====
<code>make install</code>
 
===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:
<code>sudo pacman -S pcsx2</code>
 
===PCSX2 Unstable===
Add or uncomment the following lines in `/etc/pacman.conf`:
<nowiki>
[Multilib]
Include = /etc/pacman.d/mirrorlist
</nowiki>
Refresh package list:
 
<nowiki>
pacman -Sy
</nowiki>
 
Download the tarball from the [AUR package page](https://aur.archlinux.org/packages/pcsx2-git), and unpack it.
Open the folder that you just unpacked in a terminal, and type:
<nowiki>
makepkg -csi
</nowiki>
This will build the package, automatically installing all dependencies. It will then prompt for your password to install the package with pacman.

Revision as of 18:06, 9 January 2015

The following is a guide on how to obtain and compile the PCSX2 source code on the Linux platform.

Obtaining the Source Code

PCSX2 is hosted on GitHub, a website where people can contribute to each others' programming projects using the Git version control software. GitHub is essentially just a showcase for your projects, to actually work on them you need to download and install Git itself.

Arch Linux: # pacman -S git

Next you are going to want to create a directory on your machine for the PCSX2 code to live in. For this example, let's say the directory you create is /home/you/workspace. You are going to want clone the remote PCSX2 repository like so:

$ cd /home/you/workspace
$ git clone https://github.com/PCSX2/pcsx2.git

You are now making a copy of the remote repository into your own directory.

Installing the Build System

PCSX2 uses the cmake build system to create project files and other things for multiple platforms, and GCC to compile on the linux platform. To install these you are going to want to run:

Arch 64: # pacman -S cmake gcc-multilib

Installing the Dependencies

PCSX2 relies on a number of 3rd party software libraries, so you are going to need to obtain those before you can compile the source code.

Arch 64: # pacman -S lib32-alsa-lib lib32-bzip2 lib32-libjpeg lib32-glew lib32-nvidia-cg-toolkit lib32-portaudio lib32-sdl lib32-libaio lib32-wxgtk2.8 lib32-soundtouch sparsehash

Compiling the Source

Note: On Arch Linux, you will need to explicitly specify to cmake where to find the config executables. You can do that by adding these flags into the build script:

-DwxWidgets_CONFIG_EXECUTABLE='/usr/bin/wx-config32-2.8' -DwxWidgets_wxrc_EXECUTABLE='/usr/bin/wxrc32-2.8'

Now that we have installed all external libraries, it is time to compile the source code! To do that, we are going to run a shell script which automates the entire process.
$ cd /home/you/workspace/pcsx2
$ sh build.sh

Running the Binary

This process may take several minutes. Once it has finished, you should be able to run the pcsx2 binary:
$ ./bin/pcsx2-dev

Additional external links