Compile ZDoom on Linux
This tutorial will guide you on the compilation of ZDoom on Linux.
Commands are shown in the tutorial that should be entered into a terminal. Commands beginning with `su
` or `sudo
` will require temporary root/superuser privileges, as will most likely any package installation.
Compilation for platforms other than LP64/LLP64 is not supported due to e.g. known visual artifacts and possibly other undiscovered issues that could lead to a bad user experience.
Install dependencies
ZDoom needs certain tools and development files in order to compile:
- Required
- gcc 4.8 or later
- make
- cmake 2.8.7 or later
- SDL 2.0.2 or later
- Mesa (if compiling GZDoom) or any other GL implementation provider. Compile GZDoom on Linux
- FMOD Ex 4.36.x or later or FMOD Studio
- Recommended
- GTK3 or GTK2
- git (needed in order to download the source and compile in commit meta data)
- nasm 0.98.39 or later (x86-32 only)
- Optional
- zlib (ZDoom has a copy of it and will be statically compiled in if not found)
- libbzip2 (possibly static)
- libjpeg (possibly static)
- libgme or game-music-emu (possibly static)
- wildmidi (possibly static)
- Runtime
- gxmessage (optional - needed to show the crash log in a window)
- kdialog (optional - for KDE users)
- fluidsynth or timidity (optional - for MIDI playback)
In addition to or instead of FMOD, OpenAL can be used for sound in which case the following are required:
- libopenal
- libmpg123
- libsndfile
Debian/Ubuntu
sudo apt-get install g++ make cmake libsdl2-dev git zlib1g-dev libbz2-dev \ libjpeg-dev libfluidsynth-dev libgme-dev libopenal-dev libmpg123-dev \ libsndfile1-dev libwildmidi-dev libgtk-3-dev timidity nasm tar chrpath
Fedora
dnf install gcc-c++ make cmake SDL2-devel git zlib-devel bzip2-devel \ libjpeg-turbo-devel fluidsynth-devel game-music-emu-devel openal-soft-devel \ libmpg123-devel libsndfile-devel wildmidi-devel gtk3-devel timidity++ nasm tar \ chrpath
openSUSE
zypper si -d gzdoom zypper in make
Mageia
a='' && [ "$(uname -m)" = x86_64 ] && a=64 urpmi gcc-c++ make cmake lib${a}sdl2.0-devel git lib${a}zlib-devel \ lib${a}bzip2-devel lib${a}jpeg-devel lib${a}fluidsynth-devel lib${a}gme-devel \ lib${a}openal-devel lib${a}mpg123-devel lib${a}sndfile-devel lib${a}wildmidi-devel \ lib${a}gtk+3.0-devel lib${a}cairo-devel TiMidity++ nasm tar chrpath
Arch Linux
ZDoom is available in Arch User Repository at http://aur.archlinux.org/packages.php?ID=16403
Install as per usual for AUR packages.
pacman -S --needed gcc make cmake sdl2 git zlib bzip2 libjpeg-turbo fluidsynth \ libgme openal mpg123 libsndfile wildmidi gtk3 timidity++ nasm tar fmodex chrpath
Gentoo
emerge -avn sys-devel/gcc sys-devel/make dev-util/cmake media-libs/libsdl2 \ dev-vcs/git sys-libs/zlib app-arch/bzip2 media-libs/libjpeg-turbo media-sound/fluidsynth \ media-libs/game-music-emu media-libs/openal media-sound/mpg123 media-libs/libsndfile \ media-sound/wildmidi x11-libs/gtk+ media-sound/timidity++ dev-lang/nasm app-arch/tar \ app-admin/chrpath
PCLinuxOS
a='' && [ "$(uname -m)" = x86_64 ] && a=64 apt-get install gcc-c++ make cmake lib${a}sdl2.0-devel git zlib1-devel \ lib${a}bzip2-devel lib${a}jpeg62-devel lib${a}fluidsynth1-devel lib${a}openal-devel \ lib${a}mpg123-devel lib${a}sndfile-devel lib${a}gtk+3.0-devel TiMidity++ nasm tar \ chrpath
Solus
sudo eopkg install g++ make cmake binutils glibc-devel pkg-config sdl2-devel \ git zlib-devel bzip2-devel libjpeg-turbo-devel fluidsynth-devel openal-soft-devel \ mpg123-devel libsndfile-devel wildmidi-devel libgtk-3-devel nasm tar chrpath
Do the following sections as normal user.
Download and prepare the source
Download the ZDoom source and create an out of tree build directory:
git clone git://github.com/rheit/zdoom.git && mkdir -pv zdoom/build cd zdoom/build
The rest of the guide will assume execution from the build directory created here.
Download FMOD
Download FMOD and extract files:
wget -nc http://zdoom.org/files/fmod/fmodapi44464linux.tar.gz && tar -xvzf fmodapi44464linux.tar.gz
Since FMOD is not ABI or API stable, is not generally a good idea to install it system wide (although one can).
Starting with commit aecff68a4, now you can compile ZDoom with OpenAL sound support and optinally disable/enable FMOD sound support. If you want to disable FMOD sound support, run:
cmake .. -DNO_FMOD=ON
and compile.
If afterwards you want to enable FMOD sound support, run:
cmake .. -DNO_FMOD=OFF
Compiling
To compile ZDoom:
a='' && [ "$(uname -m)" = x86_64 ] && a=64 c="$(lscpu -p | grep -v '#' | sort -u -t , -k 2,4 | wc -l)" ; [ "$c" -eq 0 ] && c=1 rm -f output_sdl/liboutput_sdl.so f='-UFMOD_LIBRARY -UFMOD_INCLUDE_DIR' && [ -d fmodapi44464linux ] && f="-DFMOD_LIBRARY=fmodapi44464linux/api/lib/libfmodex${a}-4.44.64.so \ -DFMOD_INCLUDE_DIR=fmodapi44464linux/api/inc" cmake .. -DCMAKE_BUILD_TYPE=Release $f && make -j$c
A development version of ZDoom will be compiled if you do not do #Latest stable version.
Assuming all goes well, a zdoom binary should be produced. To start ZDoom, the following command should work:
./zdoom
If ZDoom complains you do not have any IWADs set up, make sure that you have your IWAD files placed in the same directory as ZDoom, in ~/.config/zdoom/, $DOOMWADDIR, or /usr/local/share/. Alternatively, you can edit ~/.config/zdoom/zdoom.ini to set the path for your IWADs.
Latest stable version
If you want to compile the latest stable version, run:
git checkout 2.8.1
and compile.
After compiling, backing up and optionally installing the latest stable version, run:
git checkout master
Backup
If you want to backup ZDoom, do the following:
Create and name a directory with the corresponding ZDoom version/revision, build type and copy zdoom and zdoom.pk3 to it. If you compiled ZDoom with FMOD sound support, copy liboutput_sdl.so to the destination directory.
k='' && [ -f CMakeCache.txt ] && k="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' CMakeCache.txt)" b='' && [ -n "$k" ] && b="-BuildType$k" o=output_sdl/liboutput_sdl.so && l='' && [ -f "$o" ] && l="$o" BACKUPZDOOM="$(sed -n 's/.*#define GIT_DESCRIPTION "\(.*\)".*/\1/p' ../src/gitinfo.h)$b" && mkdir -pv "$BACKUPZDOOM" && cp -v zdoom zdoom.pk3 $l \ "$BACKUPZDOOM"/
Updating
When you wish to update ZDoom, copy and paste the following:
git pull
When the update finish, go to #Compiling.
Installation
- zdoom = Stable version
- zdoom-alpha = Development version
If you want to install ZDoom, do the following:
Create /usr/games/zdoom and /usr/games/zdoom-alpha directories:
sudo mkdir -pv /usr/games/zdoom /usr/games/zdoom-alpha
Copy zdoom and zdoom.pk3 to /usr/games/zdoom/ or /usr/games/zdoom-alpha/. If you compiled ZDoom with FMOD sound support, copy liboutput_sdl.so and the FMOD library file to the destination directory.
a='' && [ "$(uname -m)" = x86_64 ] && a=64 h="$(sed -n 's/.*#define GIT_HASH "\(.*\)".*/\1/p' ../src/gitinfo.h)" d='' && [ -z "$(git describe --exact-match --tags $h 2>/dev/null)" ] && d=-alpha o=output_sdl/liboutput_sdl.so && l='' && [ -f "$o" ] && l="$o \ fmodapi44464linux/api/lib/libfmodex${a}-4.44.64.so" chrpath -r '$ORIGIN' zdoom sudo cp -v zdoom zdoom.pk3 $l \ /usr/games/zdoom$d/
Create launch script:
h="$(sed -n 's/.*#define GIT_HASH "\(.*\)".*/\1/p' ../src/gitinfo.h)" d='' && [ -z "$(git describe --exact-match --tags $h 2>/dev/null)" ] && d=-alpha printf %s "\ #!/bin/sh exec /usr/games/zdoom$d/zdoom \"\$@\" " > zdoom$d.sh chmod 755 zdoom$d.sh sudo mv -v zdoom$d.sh /usr/bin/zdoom$d
Now from a terminal you should be able to run zdoom or zdoom-alpha from any user account.
Uninstallation
Remove /usr/games/zdoom directory and all its files:
sudo rm -rfv /usr/games/zdoom
Remove zdoom script:
sudo rm -fv /usr/bin/zdoom
Remove /usr/games/zdoom-alpha directory and all its files:
sudo rm -rfv /usr/games/zdoom-alpha
Remove zdoom-alpha script:
sudo rm -fv /usr/bin/zdoom-alpha
Developing
This page has helped you compile ZDoom, but perhaps you are interested in debugging the code or submitting code changes or fixes for inclusion. This section is intended for more advanced users who may be unfamiliar to CMake or debugging on Linux systems.
Debugging
Prerequisite:
Maybe you have found a way to make ZDoom crash, and are interested in debugging it. First, you need to compile a debug build of ZDoom. Inside the build directory, invoke CMake to set up for compiling, but this time, the build type is set to Debug:
cmake .. -DCMAKE_BUILD_TYPE=Debug
Optionally, you may want to use some of the #Build options.
After CMake is done, run make
or to speed up compilation, run make -j<number>
, a recommended value for the -j
option is the number of physical cores:
make
To run ZDoom under a debugger such as gdb, use the following command:
gdb zdoom
Now gdb should have you in its own command prompt:
(gdb)
You probably want to log the output, so lets output to a file zdoomdebug.log:
(gdb) set logging on zdoomdebug.log
Now start ZDoom by typing in run, and pressing enter:
(gdb) run
Or put any command line parameters to zdoom after run:
(gdb) run <command line parameters>
If ZDoom crashes, gdb may be able to tell you the source file and line number it crashed in. Typing in the command backtrace or bt will produce information telling the last function calls, showing how execution got to the point where it crashed:
(gdb) backtrace
All output will be copied into the zdoomdebug.log, which can then be scrutinized later, or perhaps posted to the Bugs forum for other developers to look at.
To exit gdb's command prompt, type quit, q or press Ctrl-D:
(gdb) quit
If you want to free up space, run make clean
to remove the files generated by the compilation.
Build options
Options | Description | Example |
---|---|---|
NO_GTK=ON | Disable GTK+ dialogs. | cmake .. -DNO_GTK=ON |
NO_FMOD=ON | Disable FMOD sound support. | cmake .. -DNO_FMOD=ON |
NO_OPENAL=ON | Disable OpenAL sound support. | cmake .. -DNO_OPENAL=ON |
FMOD_LIBRARY | Set path for FMOD library file. | cmake .. -DFMOD_LIBRARY=/path/to/libfmodex(64)-x.y.z.so |
FMOD_INCLUDE_DIR | Set path for FMOD include directory. | cmake .. -DFMOD_INCLUDE_DIR=/path/to/include/dir |
CMAKE_C_COMPILER | Set path for C compiler. | cmake .. -DCMAKE_C_COMPILER=/path/to/compiler/gcc |
CMAKE_CXX_COMPILER | Set path for C++ compiler. | cmake .. -DCMAKE_CXX_COMPILER=/path/to/compiler/g++ |
Types | Description | Example |
---|---|---|
Debug | Debug information, -O1 optimization. | cmake .. -DCMAKE_BUILD_TYPE=Debug |
Release | No debug information, -O3 optimization. | cmake .. -DCMAKE_BUILD_TYPE=Release |
RelWithDebInfo | Debug information, -O2 optimization. Useful for finding optimization bugs that only show up in Release. | cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo |
MinSizeRel | Similar to Release but with less optimizations in order to save space. | cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel |
Troubleshooting
Sound
If ZDoom starts but immediately closes with the following messages in the terminal:
... Init Playloop state. Setting up sound. S_Init Checking network game status. player 1 of 1 (1 nodes)
This usually indicates that FMOD Ex is not loading correctly (and ZDoom is configured to use FMOD by default). There are then two solutions.
You could start ZDoom without music:
zdoom -nomusic
or you could select (in the ZDoom settings) a MIDI device other than FMOD. To change MIDI device, go to the sound options menu.
- OPL synth emulation can work out of the box without further configuration.
- To install TiMidity++:
- ... on any Debian/Ubuntu-based distribution, run:
sudo apt-get install timidity timidity-interfaces-extra
- ... on openSUSE:
yast2 -i timidity or zypper in timidity
- ... on Gentoo, run:
sudo emerge -avn timidity++
See the software synthesizer article for further information about ZDoom's MIDI devices.