Compile ZDoom on Linux

From ZDoom Wiki

(Redirected from Linux)
Jump to: navigation, search

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` and `sudo` will require temporary root/admin privileges, as will most likely any package installation.

Contents

Install dependencies

ZDoom needs certain dependencies in order to compile. These versions are known to work with recent ZDoom versions:

You can presumably use any higher versions of these programs, however that might not be the case.

Debian / Ubuntu / Kubuntu

sudo apt-get install build-essential zlib1g-dev libsdl1.2-dev libjpeg62-dev nasm tar bzip2 libgtk2.0-dev cmake

OpenSUSE

As root: zypper install make gcc-c++ zlib-devel SDL-devel libjpeg-devel nasm gtk2-devel cmake

(FMOD available in RPM format from third-party repositories. At your option, you can also use yast2 instead of zypper.)

Gentoo

As root: emerge -avn sys-devel/gcc media-libs/fmod media-libs/libsdl dev-lang/nasm

Make sure the versions of these packages are equal to or greater than one of the versions listed above.

Get the ZDoom Sources

It is recommended that you use a recent version from the Subversion Repository to compile, but you may use an older version's source from the ZDoom Downloads Page if desired. Note that compilation steps may differ for older versions.

To obtain the latest version from the SVN, use the following command:

svn checkout http://mancubus.net/svn/hosted/zdoom/zdoom/trunk

A directory trunk will be generated containing the latest source code. In the future, the code may become out-of-date compared to newer code available in the SVN. To update to the latest code at any time, use the following command from inside the trunk directory:

svn update

Get the FMOD package

ZDoom uses the FMOD Ex library for audio. In many distributions, this will need to be installed manually. Check your system's package manager first to see if FMOD Ex is supported, and install it from there if it is and skip this section. Otherwise, run the following commands to install FMOD Ex:

wget http://www.fmod.org/index.php/release/version/fmodapi42627linux.tar.gz
tar -xvzf fmodapi42627linux.tar.gz

Note that if you are on a 64-bit system, you will want the 64-bit version; use the following commands to get that instead. (You can have both the 32- and 64-bit versions installed concurrently, and this may be desirable if you wish to be able to use FMOD Ex with both 32- and 64-bit applications.)

# to get the 64-bit version
wget http://www.fmod.org/index.php/release/version/fmodapi42627linux64.tar.gz
tar -xvzf fmodapi42627linux64.tar.gz

Now that the library has been downloaded and extracted, you may choose to install it or place it in the ZDoom directory tree. If you will not be installing ZDoom but running directly from the location where it is compiled, installing FMOD Ex is not strictly required, and you can place it in the trunk directory. (As installing ZDoom is not officially supported, you should probably choose this option.) This has the advantage that you can easily have multiple versions of FMOD on your system with no conflicts between each other:

mv fmodapi42627linux trunk

If instead, you would like to install FMOD Ex to /usr/local, you can do so:

cd fmodapi42627linux # or fmodapi42627linux64 for the 64-bit version
sudo make install

You will be prompted for your password, and assuming you have correct administrator privileges, FMOD Ex will be installed.

Compile

ZDoom uses CMake to handle makefile generation on Linux, so simply running make will not build zdoom until you have used CMake first. First, we need to go into the trunk directory where the source is, if we aren't there yet:

cd trunk

Next, we need to make a directory for CMake to work from, and compile to.

mkdir release
cd release

Invoke CMake to parse the ZDoom source and get ready for compiling:

cmake -DCMAKE_BUILD_TYPE=Release ..

It may be necessary to tell it where the FMOD files and includes are located, for example use this command if you installed version 4.26.27 of FMOD:

cmake -DCMAKE_BUILD_TYPE=Release -DFMOD_LIBRARY=/usr/local/lib/libfmodex-4.26.27.so -DFMOD_INCLUDE_DIR=/usr/local/include/fmodex/ ..

In case 64-bit FMOD is used, it of course needs to point to that instead.

-DFMOD_LIBRARY=/usr/local/lib64/libfmodex64-4.26.27.so

Compile the code from inside the release directory.

make

Start Playing ZDoom

Assuming all goes well, an executable zdoom and the zdoom.pk3 file will be generated in the release directory. 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 $HOME/.zdoom, $DOOMWADDIR, or /usr/local/share.

Troubleshooting

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)

Then you can either start ZDoom without music:

zdoom -nomusic

Or install Timidity (a program to play MIDI and MOD music files in software). To install Timidity...

sudo apt-get install timidity
yast2 -i timidity or zypper in timidity
sudo emerge -avn timidity++

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

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 trunk directory, create a new directory debug.

mkdir debug
cd debug

Invoke CMake to set up for compiling, but this time, the build type is set to Debug.

cmake -DCMAKE_BUILD_TYPE=Debug ..

After CMake is done, run make as usual.

To run zdoom under a debugger such as gdb, use the following command:

gdb zdoom

Now gdb should have you in its own prompt. You probably want to log the output, so lets output to a file log.txt:

set logging on log.txt

Now start zdoom by typing in run, and pressing enter. (Put any arguments to zdoom after run .) If zdoom crashes, gdb may be able to tell you the source file and line number it crashed in. Typing in the command backtrace will produce information telling the last function calls, showing how execution got to the point where it crashed. All output will be copied into the log.txt, which can then be scrutinized later, or perhaps posted to the Bugs forum for other developers to look at.

To get out of gdb's prompt, type quit.

Links

Personal tools
Namespaces
Variants
Actions
Navigation
ACS
DECORATE
ZDoom mods
Toolbox