PCSX2 Documentation/Compiling on Linux: Difference between revisions

From PCSX2 Wiki
Jump to navigation Jump to search
m (Honesty in labeling.)
 
(56 intermediate revisions by 8 users not shown)
Line 1: Line 1:
The following is a guide on how to obtain and compile the PCSX2 source code on the Linux platform.
The following is a guide on how to obtain and compile the PCSX2 source code on the Linux platform.
'''For a more in-depth guide on the PCSX2 build process, please don't refer to this guide here, as it is massively outdated:'''
*[[PCSX2 Documentation/PCSX2 Build Scripts]]


==Obtaining the Source Code==
==Obtaining the Source Code==
Line 7: Line 10:
*'''Arch Linux:''' <code># pacman -S git</code>
*'''Arch Linux:''' <code># pacman -S git</code>
*'''Debian:''' <code># apt-get install git</code>
*'''Debian:''' <code># apt-get install git</code>
*'''Fedora:''' <code># dnf install git</code>


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:
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/your/workspace. You are going to want clone the remote PCSX2 repository like so:


<code>$ cd /home/you/workspace</code><br />
<source lang="bash">
<code>$ git clone https://github.com/PCSX2/pcsx2.git</code>
$ cd /home/your/workspace
$ git clone git@github.com:PCSX2/pcsx2.git --recurse
</source>


You are now making a copy of the remote repository into your own directory.
You are now making a copy of the remote repository into your own directory.
Line 17: Line 23:
==Setting up the Build System==
==Setting up 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.
PCSX2 uses the cmake build system to create project files and other things for multiple platforms, and GCC or clang to compile on the linux platform.
 
Quick compile instructions:
 
{| class="wikitable"
|+ Compiling a release build.
|-
! Compiler/build system !! command
|-
| gcc/make || mkdir build && cd build && cmake --preset=gcc-release .. && make -j <number of jobs. Say 4 or 6 if you aren't sure.>
|-
| gcc/ninja || mkdir build && cd build && cmake --preset=gcc-release-ninja .. && ninja
|-
| clang/ninja/lld || mkdir build && cd build && cmake --preset=clang-release .. && ninja
|}
 
And run bin/pcsx2-qt .
 
=== Compiling ===
 
To compile on linux, you will need git, cmake, and a compiler. For a compiler, gcc and clang are supported. If you are going to use the clang presets, also install lld as a linker. You'll also need make or ninja. Ninja is recommended, and required if using the clang presets.
 
====Arch====
 
The required packages to compile PCSX2 can be installed with:
<code># pacman -S cmake gcc</code>
 
and optionally:
<code># pacman -S clang lld ninja</code>
 
(base-devel has gcc in it as well, and may be a good idea to install.)
 
====Fedora====
 
The required packages to compile PCSX2 can be installed with:
<code># sudo yum install cmake g++</code>
 
and optionally:
<code># sudo yum install ninja-build lld clang</code>
 
====Ubuntu====
 
The required packages to compile PCSX2 can be installed with:
<code># sudo apt install cmake g++</code>
 
and optionally:
<code># sudo apt install ninja-build lld clang</code>
 
(Like Arch, if you're having trouble, install build-essential)
 
====openSUSE====


===64-bit Arch===
The required packages to compile PCSX2 can be installed with:
<code>sudo zypper install cmake gcc gcc-c++</code>


If you are running 64-bit Arch Linux, you are going to need to enable access to the multilib repository, so you can obtain 32-bit libraries. You can do this by uncommenting the following lines in <code>/etc/pacman.conf</code>:
and optionally:
<nowiki>
<code># sudo zypper install ninja-build lld llvm-clang</code>
[Multilib]
Include = /etc/pacman.d/mirrorlist</nowiki>


Next run:
(Not absolutely sure the latter is correct. Could use testing.)
<nowiki>pacman -S cmake gcc-multilib</nowiki>


==Installing the Dependencies==
==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.
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. Here's a non-exhaustive list of these dependencies.</br>
 
If you don't have the following, it will use prebundled versions:
<source lang="bash">
sdl2 >= 2.0.22
fmt >= 7.1.3
rapidyaml >= 0.4.0
zstd >= 1.4.5
libzip >= 1.8.0
</source>
 
You have to have:
<source lang="bash">
pcap
liblzma
libaio
libsoundtouch
qt6
</source>
 
If your distribution has development versions of packages, you'll probably need those packages as well. With qt 6, we're probably talking something like:</br>
'''Fedora:'''
<source>yum install qt6-qtbase-devel qt6-qtbase-private-devel qt6-qttools-devel</source>
 
'''OpenSuse:'''
<source>sudo zypper install qt6-base-devel qt6-base-private-devel qt6-tools-devel qt6-linguist-devel</source>


'''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>
'''Ubuntu:'''
<source>apt install qt6-base-dev qt6-base-private-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools</source>
 
(All of those worked at one point, but need to be doublechecked.)


==Compiling the Source==
==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:
If you didn't already get pcsx2's source, run:</br>
<code>$ git clone git@github.com:PCSX2/pcsx2.git --recurse</code>


<code>-DwxWidgets_CONFIG_EXECUTABLE='/usr/bin/wx-config32-2.8'</code>
Now go into the pcsx2 directory:
<code>-DwxWidgets_wxrc_EXECUTABLE='/usr/bin/wxrc32-2.8'</code>
<source>$ cd ./pcsx2</source>
If you forgot the "--recurse" part when cloning, run this command:
<source>$ git submodule --init --recursive</source>
Now, make a build directory:
<source>$ mkdir -p ./build && cd ./build</source>


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 />
Now, it is time to compile the source code! Easiest way to do that is with a preset.<br />
<code>$ cd /home/you/workspace/pcsx2</code><br />
 
<code>$ sh build.sh</code>
If you're using gcc/make:
<source lang="bash">$ cmake --preset=gcc-release ..
$ make -j <number of jobs. Say 4 or 6 if you aren't sure.></source>
 
If you are using gcc & ninja:
<source lang="bash">$ cmake --preset=gcc-release-ninja ..
$ ninja</source>
 
And if you are using clang with lld and ninja:
<source lang="bash">$ cmake --preset=clang-release ..  
$ ninja</source>
 
Here's a full list, if you want a different preset:
{| class="wikitable"
|+ For reference, here is the current list of presets:
|-
! Name !! Description
|-
| ninja-multi || Generates ninja build files for debug/devel/and release builds for gcc.
|-
| gcc-debug || For making a debug build with gcc and make.
|-
| gcc-devel || For making a development build with gcc and make.
|-
| gcc-release || For making a release build with gcc and make. Does not have LTO.
|-
| gcc-debug-ninja || For making a debug build with gcc and ninja. (ninja builds faster then make.)
|-
| gcc-devel-ninja || For making a development build with gcc and ninja.(ninja builds faster then make.)
|-
| gcc-release-ninja || For making a release build with gcc and ninja. Does not have LTO. (ninja builds faster then make.)
|-
| clang-debug || For making a debug build with clang and ninja. (Fastest builds.)
|-
| clang-devel || For making a development build with clang and ninja. (Fastest builds.)
|-
| clang-release || For making a release build with clang and ninja. (This one has lto, so has the slowest build time.)
|}
 
If omit any of the libraries or headers specified above (or other, newer dependencies not included here), CMake will abort, your compiler may skip certain parts of the overall build or the linker may fail to link all the dependencies into the final PCSX2 executable. The output from any one of these tools should be able to tell the dependencies you're missing.


==Running the Binary==
==Running the Binary==


This process may take several minutes. Once it has finished, you should be able to run the pcsx2 binary:<br />
This process may take several minutes. Once it has finished, you should be able to run the pcsx2 binary, which should've been output to the <code>build/bin/</code> directory.
<code>$ ./bin/pcsx2-dev<br />


==Additional external links==
<source lang="bash">$ ./bin/pcsx2-qt</source>
 
==Additional external, likely outdated links==
* [http://forums.pcsx2.net/Thread-PCSX2-for-Debian-Ubuntu PCSX2 for Debian/Ubuntu]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Debian-Ubuntu PCSX2 for Debian/Ubuntu]
* [http://www.noobslab.com/2013/01/install-ps2-emulator-in-ubuntu.html A guide on how to setup PCSX2 in Ubuntu]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Archlinux PCSX2 for Archlinux]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Archlinux PCSX2 for Archlinux]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Fedora PCSX2 for Fedora]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Fedora PCSX2 for Fedora]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Gentoo PCSX2 for Gentoo]
* [http://forums.pcsx2.net/Thread-PCSX2-for-Gentoo PCSX2 for Gentoo]


[[Category:Guides]]
 
{{General articles}}
{{PCSX2 Documentation Navbox}}

Latest revision as of 04:33, 13 January 2023

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

For a more in-depth guide on the PCSX2 build process, please don't refer to this guide here, as it is massively outdated:

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
  • Debian: # apt-get install git
  • Fedora: # dnf install 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/your/workspace. You are going to want clone the remote PCSX2 repository like so:

<source lang="bash"> $ cd /home/your/workspace $ git clone [email protected]:PCSX2/pcsx2.git --recurse </source>

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

Setting up the Build System

PCSX2 uses the cmake build system to create project files and other things for multiple platforms, and GCC or clang to compile on the linux platform.

Quick compile instructions:

Compiling a release build.
Compiler/build system command
gcc/make mkdir build && cd build && cmake --preset=gcc-release .. && make -j <number of jobs. Say 4 or 6 if you aren't sure.>
gcc/ninja mkdir build && cd build && cmake --preset=gcc-release-ninja .. && ninja
clang/ninja/lld mkdir build && cd build && cmake --preset=clang-release .. && ninja

And run bin/pcsx2-qt .

Compiling

To compile on linux, you will need git, cmake, and a compiler. For a compiler, gcc and clang are supported. If you are going to use the clang presets, also install lld as a linker. You'll also need make or ninja. Ninja is recommended, and required if using the clang presets.

Arch

The required packages to compile PCSX2 can be installed with: # pacman -S cmake gcc

and optionally: # pacman -S clang lld ninja

(base-devel has gcc in it as well, and may be a good idea to install.)

Fedora

The required packages to compile PCSX2 can be installed with: # sudo yum install cmake g++

and optionally: # sudo yum install ninja-build lld clang

Ubuntu

The required packages to compile PCSX2 can be installed with: # sudo apt install cmake g++

and optionally: # sudo apt install ninja-build lld clang

(Like Arch, if you're having trouble, install build-essential)

openSUSE

The required packages to compile PCSX2 can be installed with: sudo zypper install cmake gcc gcc-c++

and optionally: # sudo zypper install ninja-build lld llvm-clang

(Not absolutely sure the latter is correct. Could use testing.)

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. Here's a non-exhaustive list of these dependencies.

If you don't have the following, it will use prebundled versions: <source lang="bash"> sdl2 >= 2.0.22 fmt >= 7.1.3 rapidyaml >= 0.4.0 zstd >= 1.4.5 libzip >= 1.8.0 </source>

You have to have: <source lang="bash"> pcap liblzma libaio libsoundtouch qt6 </source>

If your distribution has development versions of packages, you'll probably need those packages as well. With qt 6, we're probably talking something like:
Fedora: <source>yum install qt6-qtbase-devel qt6-qtbase-private-devel qt6-qttools-devel</source>

OpenSuse: <source>sudo zypper install qt6-base-devel qt6-base-private-devel qt6-tools-devel qt6-linguist-devel</source>

Ubuntu: <source>apt install qt6-base-dev qt6-base-private-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools</source>

(All of those worked at one point, but need to be doublechecked.)

Compiling the Source

If you didn't already get pcsx2's source, run:
$ git clone [email protected]:PCSX2/pcsx2.git --recurse

Now go into the pcsx2 directory: <source>$ cd ./pcsx2</source> If you forgot the "--recurse" part when cloning, run this command: <source>$ git submodule --init --recursive</source> Now, make a build directory: <source>$ mkdir -p ./build && cd ./build</source>

Now, it is time to compile the source code! Easiest way to do that is with a preset.

If you're using gcc/make: <source lang="bash">$ cmake --preset=gcc-release .. $ make -j <number of jobs. Say 4 or 6 if you aren't sure.></source>

If you are using gcc & ninja: <source lang="bash">$ cmake --preset=gcc-release-ninja .. $ ninja</source>

And if you are using clang with lld and ninja: <source lang="bash">$ cmake --preset=clang-release .. $ ninja</source>

Here's a full list, if you want a different preset:

For reference, here is the current list of presets:
Name Description
ninja-multi Generates ninja build files for debug/devel/and release builds for gcc.
gcc-debug For making a debug build with gcc and make.
gcc-devel For making a development build with gcc and make.
gcc-release For making a release build with gcc and make. Does not have LTO.
gcc-debug-ninja For making a debug build with gcc and ninja. (ninja builds faster then make.)
gcc-devel-ninja For making a development build with gcc and ninja.(ninja builds faster then make.)
gcc-release-ninja For making a release build with gcc and ninja. Does not have LTO. (ninja builds faster then make.)
clang-debug For making a debug build with clang and ninja. (Fastest builds.)
clang-devel For making a development build with clang and ninja. (Fastest builds.)
clang-release For making a release build with clang and ninja. (This one has lto, so has the slowest build time.)

If omit any of the libraries or headers specified above (or other, newer dependencies not included here), CMake will abort, your compiler may skip certain parts of the overall build or the linker may fail to link all the dependencies into the final PCSX2 executable. The output from any one of these tools should be able to tell the dependencies you're missing.

Running the Binary

This process may take several minutes. Once it has finished, you should be able to run the pcsx2 binary, which should've been output to the build/bin/ directory.

<source lang="bash">$ ./bin/pcsx2-qt</source>

Additional external, likely outdated links