# How to build the SDK on Linux

## Introduction

This is a guide on how to compile the SDK on linux and package your mod. It assumes basic knowledge of linux, the command line, and using a package manager for your particular distribution.

## Requirements

• A fairly modern linux distribution
• The SDK v1.3.1 package (torrent)
• GCC 4.x
• Scons 0.96 - distribution specific
• X11 development libraries, usually called libx11-dev
• OpenGL development libraries, usually called xlibmesa-gl-dev - distribution specific

Please note that you MUST use GCC 3.3 if compiling any SDK prior to v1.3.1. The guide will go over how to deal with a system having more than one version of GCC.

## Step 1. Unpacking the SDK

After you have downloaded the SDK, you need to run the file to extract and install the files. On most systems, the .run file will need to be granted execute permission before it can be run.

linux $chmod +x doom3-linux-1.3.1302-sdk.x86.run Then, run the file, and follow the on screen instructions. This guide is going to assume that the package was extracted to /usr/local/games/doom3-sdk, but you can extract it to where ever you would like. Note that if you want to install it to the default location, you will need to be root. The example below shows the usage of sudo to achieve root, but you can also use su or simply install it to another user-writable directory. linux$ sudo ./doom3-linux-1.3.1302-sdk.x86.run

Afterwards, you might want to give everyone write access to the sdk folder, so a plain user can make changes:

linux $sudo chmod -R 777 /usr/local/games/doom3-sdk ## Step 2. Running scons If you have all of the libraries set up and GCC is the default compiler, then compiling the SDK should be as simple as: linux$ cd /usr/local/games/doom3-sdk/src

### Building on x86_64 (AMD64)

If you are compiling in a native 64-bit environment, it will be necessary to tell GCC to compile and link objects in 32-bit mode.

The provided scons configuration file does not include a mechanism to modify the linker flags, so you must do it manually. Edit the file src/SConstruct , here you will see the following around line 274:

BASELINKFLAGS = [ ]

This line specifies a list of strings which should be used as link flags. Modify this line to be:

BASELINKFLAGS = [ "-m32" ]

This will allow objects to be linked in 32-bit mode. You must now instruct scons to tell GCC you want to compile the objects in 32-bit mode. This can be accomplished by setting the BASEFLAGS for scons with:

linux $scons BASEFLAGS="-m32" Note: You may need to install libc6 before compiling. Debian / Ubuntu users can do this by executing “sudo apt-get install libc6-dev-i386”. ## Packaging the file into a pk4 Now, package everything into a pk4 for inclusion with your mod. First, you’ll need a file called binary.conf, and it needs to contain a single “2”. linux$ echo "2" > binary.conf

Next you will need to rename your gamex86-xxxx.so file by removing either the -base or -d3xp suffix, depending on if your building for vanilla Doom 3 or the expansion respectively.

Then throw the renamed gamex86.so and binary.conf into a zip file named (for example) game01.pk4:

linux $zip game01.pk4 gamex86.so binary.conf This will generate a zip file called game01.pk4 containing gamex86.so and binary.conf. If you are building for the expansion, be sure to use the proper gamex86.so. Note that you can get scons to build the appropriate pk4s for you by calling it as such: linux$ scons BUILD_GAMEPAK=1

As with any other scons option, it is saved in your site.conf, so you only have to use that argument the first time.