Building Dolphin on Linux: Difference between revisions

From Dolphin Emulator Wiki
Jump to navigation Jump to search
(On the step of pulling git submodules, the recursive tage should be used so the submodules of the submodules download. CMake will spit this out as an error if you run CMake without doing so.)
m (Protected "Building Dolphin on Linux": High traffic page: Page currently linked in the guides section from the main website. If you want to add new content, please to that directly on the corresponding GitHub page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Users running Linux distros have to build Dolphin from source. Dolphin is compatible with x86-64 and AArch64 Linux distributions. This is a guide to compiling Dolphin using the cmake build system.
This page has been moved to GitHub. '''[https://github.com/dolphin-emu/dolphin/wiki/Building-for-Linux Click here to be redirected]'''.
 
For help on building on Ubuntu-based distros, such as ''Linux Mint'', ''Elementary OS'', ''Zorin OS'', ''Bodhi Linux'', ''Deepin'', ''Linux Lite'', ''Pinguy OS'', ''Kubuntu'', ''Xubuntu'', ''Lubuntu'', ''Ubuntu GNOME'', ''Edubuntu'', ''Ubuntu Studio'' or ''Mythbuntu'', see [[#Ubuntu|the instructions for Ubuntu]] below.
 
== Step 1 - Installing the Dependencies ==
=== Ubuntu ===
Follow the steps below only if you like to make your own package or use a specific git commit version. There's a [https://wiki.dolphin-emu.org/index.php?title=Installing_Dolphin#Ubuntu PPA] with Dolphin already built, easy to use.
 
==== 18.04 LTS and up ====
''Follow this step for Ubuntu 18.04 LTS and later. It probably also works for Debian GNU/Linux 10.''<br>
Install all necessary packages by running the following command:
 
<pre>sudo apt install --no-install-recommends ca-certificates qtbase5-dev qtbase5-private-dev git cmake make gcc g++ pkg-config libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxi-dev libxrandr-dev libudev-dev libevdev-dev libsfml-dev libminiupnpc-dev libmbedtls-dev libcurl4-openssl-dev libhidapi-dev libsystemd-dev libbluetooth-dev libasound2-dev libpulse-dev libpugixml-dev libbz2-dev libzstd-dev liblzo2-dev libpng-dev libusb-1.0-0-dev gettext</pre>
 
Add -DUSE_SHARED_ENET=ON on cmake line if you want to build Dolphin against shared libenet-dev.
 
=== Fedora ===
[https://wiki.dolphin-emu.org/index.php?title=Installing_Dolphin#Fedora Quick method] for Fedora 24 and later.
 
==== 23 ====
These dependencies must be installed.
 
<pre>dnf install cmake git gcc-c++ libXext-devel libgudev qt5-devel systemd-devel openal-soft-devel libevdev-devel libao-devel SOIL-devel libXrandr-devel pulseaudio-libs-devel bluez-libs-devel libusb-devel </pre>
 
The following dependencies are best from [https://rpmfusion.org/ RPM Fusion] and may not be provided in Fedora repos.
<pre>dnf install ffmpeg ffmpeg-devel</pre>
 
=== OpenSuse Tumbleweed ===
The following will be needed to build dolphin properly on OpenSuse Tumbleweed. There are some oddities with cmake not finding headers for libraries so it falls back to Externals.
 
<pre>sudo zypper install --no-recommends git cmake gcc-c++ fmt-devel Mesa-libGL-devel libX11-devel Mesa-libEGL-devel qt6-base-private-devel ffmpeg-5 ffmpeg-5-libavcodec-devel ffmpeg-5-libavformat-devel ffmpeg-5-libavutil-devel ffmpeg-5-libswscale-devel ffmpeg-5-libswscale-devel libXi-devel libXrandr-devel systemd-devel libevdev-devel sfml2-devel libminiupnpc-devel mbedtls-devel libcurl-devel libhidapi-devel bluez-devel alsa-devel libpulse-devel pugixml-devel libbz2-devel libzstd-devel lzo-devel xz-devel libpng16-devel libusb-1_0-devel gettext-runtime</pre>
 
When using pipewire-libjack will make the build fails not finding the libraries. This is a problem with the cubeb library included in dolphin. You can workaround using <pre>LDFLAGS="${LDFLAGS} `pkg-config --libs jack`" make</pre>
 
=== Other Linux Distributions ===
If running another distribution, see the build dependencies in [[#Addendum A|Addendum A]] for a list of packages needed to install.
 
== Step 2 - Get the Dolphin Repository ==
Install git if it's not already installed:
*for apt-based distros (eg Ubuntu, Debian, Linux Mint): <code>sudo apt install git</code>
*for rpm-based distros (eg Red Hat, Fedora): <code>su -c 'dnf install git'</code>
*for openSUSE: <code>sudo zypper in git</code>
*for pacman-based distros (eg Arch Linux): <code>sudo pacman -S git</code>
 
Get a local copy of the dolphin-emu repository:
 
<code>git clone https://github.com/dolphin-emu/dolphin.git dolphin-emu</code>
 
Change to the directory created.
 
<code>cd ./dolphin-emu</code>
 
Pull the git submodules.
 
<code>git submodule update --init --recursive</code>
 
To update the local copy in the future without repeating the whole process, run <code>git pull origin</code> within the <code>dolphin-emu</code> directory and proceed to the following steps.
 
 
For building the current stable (5.0) instead of the most current development build; run the following command
 
<code>git checkout tags/5.0</code>
 
== Step 3 - Building Dolphin ==
Create a build subdirectory, and change into it. The name ''Build'' is used in this example.
 
<code>mkdir Build && cd Build</code>
 
Configure the build. Note that in some cases you will need to configure in the dolphin-emu directory in stead of the build directory.
 
<code>cmake ..</code>
 
If you are using a different gcc version (7 on Ubuntu 16.04 for example), you'll need to overwrite some flags:
 
<code>cmake .. -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 </code>
 
You can compile with clang too:
 
<code>cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-stdlib=libc++</code>
 
Note that you will have to add libc++-dev and libc++abi-dev as dependence in this case. Clang minimum version is 3.4. Use SFML and pugixml from Externals/ (the latter is only necessary for {{revision|5.0-7026}} and later), otherwise you'll get some '''[https://hastebin.com/raw/etarucuged undefined references]'''.
 
Optionally you can change the install prefix by adding "-DCMAKE_INSTALL_PREFIX=/new/path". Note that this path does not need to be absolute. cmake will complete it to its absolute equivalent. The default prefix is "/usr". This means that the executable will be installed as "/usr/bin/dolphin-emu", the plugins will be installed into "/usr/lib/dolphin-emu", and the shared data files will be installed into "/usr/share/dolphin-emu".
 
From here build and install in the standard make way.
 
<code>make -j$(nproc)
 
sudo make install</code>
 
Note that superuser privileges are needed for <code>make install</code>.
 
To have the "local" build setup from the deprecated scons build configure the build with the following command.
 
<code>cmake -Dbindir=../Binary/Linux -Ddatadir=../Binary/Linux  ..</code>
 
== Step 4 - Run Dolphin! ==
Run Dolphin by executing:
 
<code>dolphin-emu</code>
 
The same action can be done graphically from within some desktop environments, such as Unity's ''Dash'' menu on Ubuntu.<br>
If the prefix was changed in step 3 and $prefix/bin is not in the path, then precede this with the path to the executable.
 
== FAQ ==
*'''Where can I get help?'''
 
Go to the [https://forums.dolphin-emu.org forums]. Lots of Dolphin users use Linux, and they are very experienced with this process.
 
*'''My build failed, but I did nothing wrong!'''
 
Most of the time, any problems in the build process are due to user error. It's understandable, it is a complicated process and can be quite daunting for a first timer. But sometimes even with everything right, triple checked, and it's still not working. It's rare, but sometimes a build will just be bugged. But many of Dolphin devs are Linux users, so just wait a day or so, and it will be sorted out. If you are trying on Ubuntu 16.04, it is tested and working now.
 
*'''I want a PKGBUILD!'''
 
Here is [https://projects.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/dolphin-emu a PKGBUILD for the stable branch]. For the master branch, see [https://aur.archlinux.org/packages/dolphin-emu-git/ this PKGBUILD] (in pkgver=4.0.rxxxx.7222eb1 replace "xxxx" with the number of the desired revision). Other PKGBUILDs can be found on the [https://aur.archlinux.org/ Arch User Repository].
 
== Addendum A ==
{{Fmbox
|text = '''Outdated'''
<br/>This section has not been updated since July 2019 and no longer aligns with Dolphin's current dependencies.
}}
This addendum lists the dependencies to build Dolphin.
 
=== Build Dependencies ===
These packages must be installed before building Dolphin.
* git
* cmake
* pkg-config
* gcc
* libwxbase3.0-dev
* libwxgtk3.0-dev
* libgtk2.0-dev
* libxext-dev
* libreadline-dev
* libgl1-mesa-dev
* libevdev-dev
* libudev-dev
 
=== Optional dependencies ===
{| class="wikitable"
! Package !! Service
|-
| libasound-dev
| for alsa sound backend
|-
| libpulse-dev
| for pulseaudio sound backend
|-
| libao-dev
| for ao sound backend
|-
| libopenal-dev
| for openal sound backend
|-
| libavcodec-dev
| for dumping frames in AVI format
|-
| libavformat-dev
| for dumping frames in AVI format
|-
| libswscale-dev
| for dumping frames in AVI format
|-
| libenet-dev (>= 1.3.12)
| if not found will be built statically
|-
| liblzo2-dev (>= 2.04)
| if not found will be built statically
|-
| libminiupnpc-dev (>= 1.8)
| if not found will be built statically
|-
| libpolarssl-dev (>= 1.3.8)
| if not found will be built statically (Debian Testing/Unstable replaced this with mbedtls, see https://ftp-master.debian.org/removals.txt)
|-
| libsoil-dev
| if not found will be built statically
|-
| libsoundtouch-dev (>= 1.8.1)
| if not found will be built statically
|-
| libsfml-dev (>= 2.1)
| if not found will be built statically
|-
| libusb-1.0-0-dev (>= 1.0.19)
| if not found will be built statically
|-
| libbluetooth-dev
| for real Wii Remotes
|-
| libxrandr-dev
| for switching desktop resolution in fullscreen mode
|}
 
== Addendum B ==
Scripts for building Dolphin.
 
=== General purpose script ===
This script checks for Dolphin's source code, downloads it or updates it, then compiles it and finally installs it. It is somewhat interactive and distro-independent.<br>
It '''will not''' install any of the dependencies listed above, and will fail if any of them are missing. Install manually as described at [[#Step 1 - Installing the Dependencies|the first step]].<br>
Licence: [https://www.gnu.org/licenses/gpl-2.0.html GNU General Public Licence v2] or (at your option) any later version of the GPL.<br>
<pre>
#!/bin/bash
 
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
getdolphin() {
echo 'Downloading Dolphin...'
git clone https://github.com/dolphin-emu/dolphin.git
}
updatedolphin() {
cd $DIR/dolphin
echo 'Updating the local repository...'
git pull origin
}
build() {
cmake $DIR/dolphin
make
}
updatedolphin || getdolphin
mkdir $DIR/build
cd $DIR/build
build && echo 'Compiled successfully.' || exit
echo 'Proceeding to the installation; press Enter to continue or Ctrl+C to cancel.'
read
if [ $(whoami) == "root" ];
then
make install
else
sudo make install
fi
</pre>
 
Instructions:
 
Put this script in any directory, preferably a subdirectory of the Home directory, such as <code>~/.scripts/dolphin</code><br>
Within this directory, the script will create two subdirectories, ''dolphin-emu'' and ''build''. It must remain in this directory to work.<br>
Execute the script from anywhere, by running <code>sh /path/to/the/script.sh</code>, where /path/to/the/script.sh is replaced with the actual path to the script.<br>
The script will download Dolphin's source, or update it if it has already been downloaded once. After building it, the script will install it. This requires root privileges. After the installation, the script exits, and Dolphin can be used. Note that the process is very fast and simple after the first time. Using a [https://askubuntu.com/a/17538 bash alias] to execute the script by running a custom command such as <code>dolphin-update</code> is recommended.
 
[[Category:Tutorials]]

Latest revision as of 05:07, 5 January 2024

This page has been moved to GitHub. Click here to be redirected.