PCSX2 Documentation/Compiling on Linux: Difference between revisions

From PCSX2 Wiki
Jump to navigation Jump to search
No edit summary
m (Should also init submodules from all recursive submodules.)
(11 intermediate revisions by 4 users not shown)
Line 10: 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/you/workspace. You are going to want clone the remote PCSX2 repository like so:
Line 24: Line 25:
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 to compile on the linux platform.


===64-bit Arch===
===32-bit compile on 64-bit machines===
====Arch====


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>:
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>:
Line 34: Line 36:
Then, just run the following:
Then, just run the following:


<source lang="bash">
<code># pacman -S cmake gcc</code>
# pacman -S cmake gcc
 
</source>
====Fedora====
 
It is important to note that you do not need to install <code>gcc-c++.i686</code>. Installing this package could lead to some packages being downgraded, resulting in a broken g++ compiler.
 
The required packages to compile PCSX2 can be installed with:
 
<code># dnf install gcc-g++ cmake glibc-devel.i686 libstdc++-devel.i686</code>


==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.  


<source lang="bash">
<source lang="bash">
Line 51: Line 59:
lib32-sdl
lib32-sdl
lib32-libaio
lib32-libaio
lib32-wxgtk2.8
lib32-wxgtk3
lib32-soundtouch
lib32-soundtouch
lib32-libpcap
lib32-zlib
lib32-libsamplerate
sparsehash
sparsehash
fmt
</source>
</source>
When generating the build configuration, CMake will first attempt to use pre-bundled versions of some of these packages to ensure PCSX2 is built against the most suitable version of its dependencies.
In order to install these pre-packaged dependencies, run the following commands at the top-level directory of the PCSX2 git repository you just cloned
<source>
$ cd ./pcsx2
$ git submodule --init --recursive
$ mkdir -p ./build && cd ./build
</source>
Please note you may still need to install 32-bit versions of some of these libraries yourself.
===Fedora===
To obtain all the required dependencies for 32-bit compile on Fedora, reference their <code>i686</code> architecture version, like so:
<pre>
# dnf install alsa-lib-devel.i686 libpcap-devel.i686 libxml2-devel.i686 freetype-devel.i686 \
  xz-devel.i686 mesa-libGL-devel.i686 libpng-devel.i686 libaio-devel.i686 systemd-devel.i686 \
  portaudio-devel.i686 soundtouch-devel.i686 SDL2-devel.i686 harfbuzz-devel.i686 wxGTK3-devel.i686 \
  gtk3.i686 gtk3-devel.i686 glib2-devel.i686 libsamplerate.i686 libsamplerate-devel.i686 gdk-pixbuf2-devel.i686
</pre>
Note: this list of dependencies was last verified on a Fedora 33 (x86_64) installation.


==Compiling the Source==
==Compiling the Source==
Line 70: Line 106:
$ sh build.sh
$ sh build.sh
</source>
</source>
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>bin/</code> directory.
<source lang="bash">$ ./bin/pcsx2-dev</source>
 
<source lang="bash">$ ./bin/PCSX2</source>
 
The most straightforward to invoke the PCSX2 binary is via the Linux wrapper script provided in the same folder, which should be run from the top-level directory:
 
<source lang="bash">
$ chmod +x ./bin/PCSX2-linux.sh
$ ./bin/PCSX2-linux.sh
</source>


==Additional external links==
==Additional external 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]

Revision as of 11:28, 26 January 2022

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 refer to this guide here:

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

<source lang="bash"> $ cd /home/you/workspace $ git clone https://github.com/PCSX2/pcsx2.git </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 to compile on the linux platform.

32-bit compile on 64-bit machines

Arch

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 /etc/pacman.conf: <source lang="apache"> [Multilib] Include = /etc/pacman.d/mirrorlist </source>

Then, just run the following:

# pacman -S cmake gcc

Fedora

It is important to note that you do not need to install gcc-c++.i686. Installing this package could lead to some packages being downgraded, resulting in a broken g++ compiler.

The required packages to compile PCSX2 can be installed with:

# dnf install gcc-g++ cmake glibc-devel.i686 libstdc++-devel.i686

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.

<source lang="bash"> lib32-alsa-lib lib32-bzip2 lib32-libjpeg lib32-glew lib32-nvidia-cg-toolkit lib32-portaudio lib32-sdl lib32-libaio lib32-wxgtk3 lib32-soundtouch lib32-libpcap lib32-zlib lib32-libsamplerate sparsehash fmt </source>

When generating the build configuration, CMake will first attempt to use pre-bundled versions of some of these packages to ensure PCSX2 is built against the most suitable version of its dependencies. In order to install these pre-packaged dependencies, run the following commands at the top-level directory of the PCSX2 git repository you just cloned

<source> $ cd ./pcsx2 $ git submodule --init --recursive $ mkdir -p ./build && cd ./build </source>

Please note you may still need to install 32-bit versions of some of these libraries yourself.

Fedora

To obtain all the required dependencies for 32-bit compile on Fedora, reference their i686 architecture version, like so:

# dnf install alsa-lib-devel.i686 libpcap-devel.i686 libxml2-devel.i686 freetype-devel.i686 \
  xz-devel.i686 mesa-libGL-devel.i686 libpng-devel.i686 libaio-devel.i686 systemd-devel.i686 \
  portaudio-devel.i686 soundtouch-devel.i686 SDL2-devel.i686 harfbuzz-devel.i686 wxGTK3-devel.i686 \
  gtk3.i686 gtk3-devel.i686 glib2-devel.i686 libsamplerate.i686 libsamplerate-devel.i686 gdk-pixbuf2-devel.i686

Note: this list of dependencies was last verified on a Fedora 33 (x86_64) installation.

Compiling the Source

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

<source lang="bash"> -DwxWidgets_CONFIG_EXECUTABLE='/usr/bin/wx-config32-2.8' -DwxWidgets_wxrc_EXECUTABLE='/usr/bin/wxrc32-2.8' </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.
<source lang="bash"> $ cd /home/you/workspace/pcsx2 $ sh build.sh </source>

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 bin/ directory.

<source lang="bash">$ ./bin/PCSX2</source>

The most straightforward to invoke the PCSX2 binary is via the Linux wrapper script provided in the same folder, which should be run from the top-level directory:

<source lang="bash"> $ chmod +x ./bin/PCSX2-linux.sh $ ./bin/PCSX2-linux.sh </source>

Additional external links