Skip to content

Commit 560d8a5

Browse files
Docs: Restructure 'Building PCSX2' article
1 parent 39716c4 commit 560d8a5

1 file changed

Lines changed: 126 additions & 85 deletions

File tree

docs/advanced/building.md

Lines changed: 126 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,136 @@ toc: true
66
sidebar_position: 1
77
---
88

9-
This page helps you build PCSX2 locally on your machine.
10-
11-
## Building on Windows
9+
import Tabs from '@theme/Tabs';
10+
import TabItem from '@theme/TabItem';
1211

13-
### Required Dependencies for Qt
12+
This page helps you build PCSX2 locally on your machine.
1413

15-
If you are developing against the `pcsx2-qt` solution, you will need to do the following:
14+
## Building the Application
1615

17-
- Download the binaries [from here](https://github.com/PCSX2/pcsx2-windows-dependencies/releases/)
18-
- tools / symbols are not required
19-
- Extract into the main folder (where the `PCSX2_qt.sln` file is); you should see a new `deps` folder after extraction
20-
- Ensure you have opened the `*-qt` .sln file.
16+
<Tabs queryString="os">
17+
<TabItem value="windows" label="Windows" default>
2118

22-
### Required Build Applications
19+
To build PCSX2 on Windows, you will need the following applications:
2320

2421
<!-- MS has a handy list with names here https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019 -->
2522

2623
- [Visual Studio Community](https://www.visualstudio.com/downloads/)
27-
- Installing just the "Desktop development with C++" workload should be enough, otherwise select individually:
28-
- C++ ATL for v142 build tools (x86 & x64)
29-
- MSVC v142 - VS 2019 C++ x64/x86 build tools
30-
- Windows 10 SDK
3124
- [Git for Windows](https://git-scm.com/download/win)
3225

33-
### Other Requirements
26+
:::note[Note – Visual Studio]
27+
28+
- Installing just the "Desktop development with C++" workload should be enough.
29+
- Otherwise, select individually:
30+
- C++ Active Template Library (ATL) for v142 build tools (x86 & x64)
31+
- MSVC v142 - VS 2019 C++ x64/x86 build tools
32+
- Windows 10 SDK
33+
:::
34+
35+
Next, in order to obtain the necessary Qt dependencies:
36+
37+
1. Download the binaries [from here](https://github.com/PCSX2/pcsx2-windows-dependencies/releases/).
38+
- Tools / symbols are not required.
39+
2. Extract into the main folder (where the `PCSX2_qt.sln` file is).
40+
- You should see a new `deps` folder after extraction.
41+
3. Ensure you have opened the `*-qt` .sln file.
42+
43+
Optionally, widescreen and no-interlacing cheats are sourced from [a separate repository](https://github.com/PCSX2/pcsx2_patches). You might consider putting them in your working directory to ensure your development environment matches shipping builds:
44+
45+
1. Download both `.zip` files from [the releases page.](https://github.com/PCSX2/pcsx2_patches/releases/)
46+
2. Place them (without extracting) in `bin/resources`.
47+
48+
</TabItem>
49+
<TabItem value="macos" label="macOS">
50+
51+
:::note[Note – Xcode]
52+
You will need to have Xcode installed to use our CI's build script.
53+
:::
54+
55+
<Tabs queryString="cpu">
56+
<TabItem value="silicon" label="Apple Silicon" default>
57+
58+
:::note[Note – Building on ARM]
3459

35-
Widescreen and No-Interlacing cheats are sourced from [a separate repository](https://github.com/PCSX2/pcsx2_patches). You might consider putting them in your working directory to ensure your development environment matches shipping builds:
60+
- PCSX2 does not support building for ARM.
61+
- On Apple Silicon, you will still need to make Intel builds and run them in Rosetta.
62+
- Dependencies from Homebrew will not work.
63+
:::
3664

37-
- Download both `.zip` files from here: https://github.com/PCSX2/pcsx2_patches/releases/
38-
- Put them (without extracting) in `bin/resources`.
65+
You will need Intel versions of all the dependencies. The dependency build script will handle this for you (see Intel instructions). If you use MacPorts, install your packages with `+universal`. We do not link to any libraries from `qt6-qttools`, so you can skip the universal on that one (and it links with libclang, so we recommend skipping it unless you really want to sit around while MacPorts builds a universal build of Clang and LLVM).
3966

40-
## Building On Linux
67+
Add the following extra flags to the CMake invocation listed in the Intel Mac section:
4168

42-
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.
69+
- `-DCMAKE_OSX_ARCHITECTURES=x86_64`
70+
- Tells CMake to do an Intel build.
4371

44-
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.
72+
</TabItem>
73+
<TabItem value="intel" label="Intel Mac">
4574

46-
- https://github.com/PCSX2/pcsx2/blob/master/.github/workflows/linux_build_qt.yml
47-
- https://github.com/PCSX2/pcsx2/tree/master/.github/workflows/scripts/linux
75+
Build the dependencies using the CI's build script: `.github/workflows/scripts/macos/build-dependencies.sh deps` (this will build the dependencies into the directory `deps`). If you want to use a package manager, you can look at the install script to see the required dependencies.
76+
77+
You can set the environment variable `BUILD_FFMPEG=0` to tell the dependency build script to build all the dependencies except ffmpeg, allowing you to use your homebrew or macports-installed ffmpeg, which probably has more features enabled than the build script's.
78+
79+
Building on an Intel Mac should work similarly to building on Linux. Run CMake with `cmake /path/to/pcsx2/source -DCMAKE_PREFIX_PATH=/path/to/deps -DCMAKE_BUILD_TYPE=Release`, then `make`. The final `.app` will be in `pcsx2-qt/PCSX2.app` in the build directory. (The `CMAKE_PREFIX_PATH` is only needed if you used the CI's build script to install dependencies.)
80+
81+
Add `-DUSE_LINKED_FFMPEG=ON` for video capture support.
82+
83+
</TabItem>
84+
</Tabs>
4885

49-
### Dependencies
86+
<details>
87+
<summary>Expand to see optional flags which may be useful for PCSX2 development</summary>
5088

51-
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.
89+
- `-DSKIP_POSTPROCESS_BUNDLE=ON`
90+
- Disables a post-build step that fixes up all the dependencies and shoves them into the app bundle for easy distribution.
91+
- Saves time on incremental builds.
92+
- `-G Xcode`
93+
- Tells CMake to generate an Xcode project instead of makefiles.
94+
- Allows you to use Xcode to work on PCSX2.
5295

53-
#### Ubuntu Package List
96+
</details>
97+
98+
</TabItem>
99+
<TabItem value="linux" label="Linux">
100+
101+
:::info[Info – Build process]
102+
The procedure outlined here closely mirrors the scripts used by the PCSX2 CI process. The following scripts provide more information behind the build process than what is stated here:
103+
104+
- [`linux_build_qt.yml`](https://github.com/PCSX2/pcsx2/blob/master/.github/workflows/linux_build_qt.yml)
105+
- [Linux workflow script](https://github.com/PCSX2/pcsx2/tree/master/.github/workflows/scripts/linux)
106+
:::
107+
108+
Dependencies and their required versions change over time. In particular, PCSX2 no longer supports the GCC compiler in favor of Clang/LLVM.
109+
110+
<Tabs queryString="distro">
111+
<TabItem value="debian" label="Debian" default>
112+
113+
The following package list is sufficient for building PCSX2 on Debian and its derivative distributions such as Ubuntu, Linux Mint, and Pop!\_OS:
54114

55115
```sh
56116
build-essential clang cmake curl extra-cmake-modules git libasound2-dev libaio-dev libavcodec-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libdbus-1-dev libdecor-0-dev libegl-dev libevdev-dev libfontconfig-dev libfreetype-dev libgtk-3-dev libgudev-1.0-dev libharfbuzz-dev libinput-dev libopengl-dev libpcap-dev libpipewire-0.3-dev libpulse-dev libssl-dev libswresample-dev libswscale-dev libudev-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-damage0-dev libxcb-glx0-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-sync-dev libxcb-util-dev libxcb-xfixes0-dev libxcb-xinput-dev libxcb-xkb-dev libxext-dev libxkbcommon-x11-dev libxrandr-dev lld llvm ninja-build pkg-config zlib1g-dev
57117
```
58118

59-
#### Fedora Package List
119+
</TabItem>
120+
<TabItem value="fedora" label="Fedora">
60121

61-
The following package list is sufficient for building PCSX2 as of 2024/04/06 with Fedora 39. You must build the third-party dependencies using the script from the CI, as instructed below.
122+
On Fedora, you must build third-party dependencies using the script from the CI as instructed below. The following package list is sufficient for building PCSX2 as of 6 April 2024 with Fedora 39:
62123

63124
```sh
64125
alsa-lib-devel brotli-devel clang cmake dbus-devel egl-wayland-devel extra-cmake-modules fontconfig-devel gcc-c++ gtk3-devel libaio-devel libcurl-devel libdecor-devel libevdev-devel libICE-devel libinput-devel libpcap-devel libSM-devel libX11-devel libXau-devel libxcb-devel libXcomposite-devel libXcursor-devel libXext-devel libXfixes-devel libXft-devel libXi-devel libxkbcommon-devel libxkbcommon-x11-devel libXpresent-devel libXrandr-devel libXrender-devel lld llvm make mesa-libEGL-devel mesa-libGL-devel ninja-build openssl-devel patch pcre2-devel perl-Digest-SHA pipewire-devel pulseaudio-libs-devel systemd-devel wayland-devel xcb-util-cursor-devel xcb-util-devel xcb-util-errors-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-renderutil-devel xcb-util-wm-devel xcb-util-xrm-devel zlib-devel
65126
```
66127

67-
#### NixOS nix-shell
128+
</TabItem>
129+
<TabItem value="arch" label="Arch">
130+
131+
On Arch, we recommend using the PKGBUILD file of the unofficial [`pcsx2-git` AUR package](https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=pcsx2-git) maintained by WeirdBeard et al. as a reference. The packages listed under `depends` and `makedepends` are all required to build PCSX2, and the `optdepends` are optionally used for RetroAchievements, Wayland support, etc.
132+
133+
:::tip[Tip – Building dependencies]
134+
On Arch, it is unlikely you will need to use the `build-dependencies-qt.sh` script discussed below, as by nature of being a rolling release distribution, your packages should always be up-to-date.
135+
:::
136+
137+
</TabItem>
138+
<TabItem value="nixos" label="NixOS">
68139

69140
```nix
70141
{ pkgs ? import <nixpkgs> { } }:
@@ -131,109 +202,79 @@ pkgs.mkShell {
131202
}
132203
```
133204

134-
### Build procedure
205+
</TabItem>
206+
</Tabs>
135207

136-
#### Clone repository
208+
First, clone and then enter the repository:
137209

138210
```sh
139211
git clone --recursive https://github.com/PCSX2/pcsx2.git
140212
cd pcsx2
141213
```
142214

143-
#### Build Dependencies
144-
145-
PCSX2 depends on multiple third-party libraries, which should be built for your development environment. We provide a convenience script for building these dependencies, which is also used by our CI runners for release builds.
215+
PCSX2 depends on multiple third-party libraries, which should be built for your development environment. We provide a convenience script, `build-dependencies-qt.sh`, for building these dependencies, which is also used by our CI runners for release builds.
146216

147-
This will build the dependencies to your PCSX2 Git tree, in the `deps` directory. You can also specify an alternative location, but be sure to adjust `CMAKE_PREFIX_PATH` in the next step.
217+
This script will build the dependencies in the `deps` directory of your PCSX2 Git tree. You can also specify an alternative location, but be sure to adjust `CMAKE_PREFIX_PATH` in the next step.
148218

149219
```sh
150220
.github/workflows/scripts/linux/build-dependencies-qt.sh deps
151221
```
152222

153-
#### Prepare build with CMake
223+
Prepare the build with CMake:
154224

155225
```sh
156226
cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" -DCMAKE_PREFIX_PATH="$PWD/deps" -GNinja
157227
```
158228

159-
Note the following optional CMake flags that are commonly used:
229+
<details>
230+
<summary>Expand to see optional, commonly used CMake flags</summary>
160231

161232
- `-DCMAKE_BUILD_TYPE=Release|Devel|Debug`
162233

163-
- `Release`: Fastest build, but lacks debug/crash information
164-
- `Devel`: Adds detailed trace logging abilities, but lacks debug/crash information
165-
- `Debug`: Slowest build as there are no compiler optimizations, but offers debug/crash information
234+
- `Release`Fastest build but lacks debug/crash information.
235+
- `Devel`Adds detailed trace logging abilities but lacks debug/crash information.
236+
- `Debug`Slowest build (no compiler optimizations) but has debug/crash information.
166237

167238
- `-DCMAKE_CXX_COMPILER_LAUNCHER=ccache`
168239

169-
- Uses ccache to speed up the build process
240+
- Uses ccache to speed up the build process.
170241

171242
- `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON`
172-
- Turns on link time optimization, which provides a noticeable performance improvement.
243+
- Turns on [link-time optimization](https://en.wikipedia.org/wiki/Interprocedural_optimization#WPO_and_LTO).
244+
- Provides a noticeable performance improvement.
245+
</details>
173246

174-
#### Execute build
247+
Next, execute the build process:
175248

176249
```sh
177250
ninja -C build
178251
```
179252

180-
#### Running PCSX2
181-
182-
PCSX2 can be launched from the build directory:
253+
Finally, PCSX2 can be launched from the build directory:
183254

184255
```sh
185256
build/bin/pcsx2-qt
186257
```
187258

188-
## Building on MacOS
189-
190-
### Building on an Intel Mac
191-
192-
Build the dependencies using the CI's build script: `.github/workflows/scripts/macos/build-dependencies.sh deps` (this will build the dependencies into the directory `deps`). If you want to use a package manager, you can look at the install script to see the required dependencies.
193-
194-
:::caution
195-
You will need to have Xcode installed to use our CI's build script.
196-
:::
197-
198-
You can set the environment variable `BUILD_FFMPEG=0` to tell the dependency build script to build all the dependencies except ffmpeg, allowing you to use your homebrew or macports-installed ffmpeg, which probably has more features enabled than the build script's.
199-
200-
Building on an Intel Mac should work similarly to building on Linux. Run cmake with `cmake /path/to/pcsx2/source -DCMAKE_PREFIX_PATH=/path/to/deps -DCMAKE_BUILD_TYPE=Release`, then `make`. The final `.app` will be in `pcsx2-qt/PCSX2.app` in the build directory. (The `CMAKE_PREFIX_PATH` is only needed if you used the CI's build script to install dependencies.)
201-
202-
Add `-DUSE_LINKED_FFMPEG=ON` for video capture support.
203-
204-
### Building on an ARM (Apple Silicon) Mac
205-
206-
:::warning
207-
PCSX2 does not support building for ARM. You will need to make Intel builds even on Apple Silicon and run them in Rosetta.
208-
:::
209-
210-
You will need Intel versions of all the dependencies. **Dependencies from Homebrew will not work.** The dependency build script will handle this for you (see Intel instructions). If you use MacPorts, install your packages with `+universal`. Note that we don't link to any libraries from `qt6-qttools`, so you can skip the universal on that one (and it links with libclang, so I'd recommend skipping it unless you really want to sit around while MacPorts builds a universal build of clang and llvm).
211-
212-
Add the following extra flags to the cmake invocation listed in the Intel Mac section:
213-
214-
- `-DCMAKE_OSX_ARCHITECTURES=x86_64`. This tells cmake to do an Intel build even though you're on an ARM Mac.
215-
216-
### Building for development
217-
218-
The following extra cmake flags may be useful when building for working on PCSX2:
219-
220-
- `-DSKIP_POSTPROCESS_BUNDLE=ON`. This disables a post-build step that fixes up all the dependencies and shoves them into the app bundle for easy distribution. Saves time on incremental builds.
221-
- `-G Xcode`. Tells cmake to generate an Xcode project instead of makefiles. Allows you to use Xcode to work on PCSX2.
259+
</TabItem>
260+
</Tabs>
222261

223262
## Building GammaRay
224263

225-
[GammaRay](https://github.com/KDAB/GammaRay) is a debugging tool that lets you inspect the internal state of Qt applications. If you're working on the UI you may find it useful to build it alongside PCSX2 with one of the provided scripts, after building or downloading PCSX2's dependencies. This is entirely optional.
226-
227-
Windows:
264+
[GammaRay](https://github.com/KDAB/GammaRay) is a free and open-source debugging tool that lets you inspect the internal state of Qt applications. After building or downloading PCSX2's dependencies, you may find it useful to build GammRay alongside PCSX2 with one of the provided scripts if you're working on the UI. This is entirely optional.
228265

266+
<Tabs queryString="os">
267+
<TabItem value="windows" label="Windows" default>
229268
```sh
230269
.github\workflows\scripts\windows\build-gammaray.bat
231270
gammaray\bin\gammaray.exe bin\pcsx2-qtx64-avx2.exe
232271
```
233272

234-
Linux:
235-
273+
</TabItem>
274+
<TabItem value="linux" label="Linux">
236275
```sh
237276
.github/workflows/scripts/linux/build-gammaray.sh deps gammaray
238277
./gammaray/bin/gammaray build/bin/pcsx2-qt
239278
```
279+
</TabItem>
280+
</Tabs>

0 commit comments

Comments
 (0)