The Dark Mod - Compilation Guide: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(Noted svnversion after major 2.06 update)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''Intended article audience:''' engine coders
'''Intended article audience:''' engine coders


This guide should provide you with enough information to compile The Dark Mod's game code from source.  
This guide should provide you with enough information to compile The Dark Mod's game code from source.
It applies to version 2.06 or later version of TDM. If you want to compile older version, see the history of this wiki page.
Brief compilation instructions are also included in <tt>COMPILING.txt</tt> file in the source code package.


The sources are available through "snapshots", i.e. whenever the Dark Mod team is releasing a new update (e.g. TDM 1.01) the corresponding sources are released as well.
The sources are available through "snapshots", i.e. whenever the Dark Mod team is releasing a new update (e.g. TDM 2.06) the corresponding sources are released as well.


== Get the sources ==
== Get the sources ==
Line 9: Line 11:
*Get the latest sources directly from SVN: https://svn.thedarkmod.com/svn/darkmod_src/trunk  
*Get the latest sources directly from SVN: https://svn.thedarkmod.com/svn/darkmod_src/trunk  


Be warned though that (unless you're a team member and working on the SVN asset base) these sources might be incompatible with your local darkmod installation. The team cannot and will not support you in case you're running into troubles trying to get it to run.
Be warned though that (unless you're a team member and working on the SVN asset base) these sources '''might be incompatible with your local darkmod installation'''. The team cannot and will not support you in case you're running into troubles trying to get it to run.


== Windows ==
Download the sources and unpack them next to your darkmod/ directory, such that the directory structure looks like this:
Since TDM 2.03 you'll need Visual Studio 2013 to compile the project (the free Community Edition works fine). A solution file for MSVS2013 is provided in TheDarkMod.sln. (Prior TDM versions were using VC++ 2010, check this page's history for instructions.)


You will need the Microsoft DirectX SDK installed as well. If it does not reside in "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)" you will need to update the property sheets accordingly.
C:\Games\Doom3\darkmod      <-- your darkmod location
C:\Games\Doom3\darkmod_src  <-- your source folder containing the solution, can be renamed


* DirectX SDK: http://www.microsoft.com/en-us/download/details.aspx?id=6812
This directory structure is recommended for both Windows and Linux.
* Multibyte MFC Library for Visual Studio 2013: http://www.microsoft.com/en-us/download/details.aspx?id=40770
* Windows SDK ''(for Windows 8.1 users)'': http://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx


Download the sources and unpack them next to your darkmod/ folder, such that the directory structure looks like this:
== Windows ==


C:\Games\Doom3\darkmod      <-- your darkmod location
Since TDM 2.03 you'll need Visual Studio 2013 to compile the project.
C:\Games\Doom3\darkmod_src  <-- your source folder containing the solution, can be renamed
The free Community Edition works fine, it can be downloaded [https://www.visualstudio.com/en-us/news/releasenotes/vs2013-community-vs#download-visual-studio-2013-community approximately here]. Additionally, you have to:
* Make sure "Microsoft Foundation Classes for C++" (MFC) is being installed by MSVC2013 installer.
* Download and install "Multibyte MFC Library for Visual Studio 2013" afterwards: http://www.microsoft.com/en-us/download/details.aspx?id=40770
 
You'll find a <tt>TheDarkMod.sln</tt> solution file (in MSVC 2013 format) in the source code folder, which you can double-click to open in Visual Studio. The solution is designed to put the compiled binaries into the ../darkmod folder nearby, that's why we recommend using the directory layout shown above. (You can change the output paths in the property sheets, in case you know how to do that).


You'll find a <tt>TheDarkMod.sln</tt> solution file (in VC++ 2013 format), which you can double-click to open in Visual Studio. The solution is designed to put the compiled binaries into the darkmod/ folder above, that's why I recommend using such a folder layout. (You can change the output paths in the property sheets, in case you know how to do that.)
Once the solution is opened, select the Configuration in the topmost toolbar (either "release" or "debug", depending on what you want to do) and Platform (either Win32 or x64). Then hit "Build Solution" ({{Ctrl}}-{{Shift}}-{{key|B}} or {{F7}}). The compilation usually takes a minute or two, watch the output window at the bottom of Visual Studio. After completion you'll find the compiled binary in your darkmod/ folder. It would be either <tt>TheDarkMod.exe</tt> or <tt>TheDarkModx64.exe</tt>, depending on the target platform you chose.


Once the solution is opened, select the Configuration Type in the topmost toolbar (either "release" or "debug", depending on what you want to do) and hit "Build Solution" ({{Ctrl}}-{{Shift}}-{{key|B}}). The compilation usually takes a minute or two, watch the output window at the bottom of Visual Studio. After completion you'll find the compiled binaries TheDarkMod.exe and gamex86.dll in your darkmod/ folder - the darkmod/tdm_game01.pk4 archive will have been updated too, there's a post-build event defined to add the DLL file into the PK4.
The code uses DirectInput, which is automatically installed with VS2013 as a part of Windows SDK.
Normally, you don't have to do anything about it.
But if you have trouble with DirectInput, you can download the deprecated "Microsoft DirectX SDK" [http://www.microsoft.com/en-us/download/details.aspx?id=6812 here].
In such case you will have to manually add paths to DirectX SDK to the property sheets.


=== Debugging the Engine/Game ===
=== Debugging the Engine/Game ===
Line 34: Line 41:
The quick one:
The quick one:
# Go to Visual Studio and open the TheDarkMod solution
# Go to Visual Studio and open the TheDarkMod solution
# Make sure the "Engine" project is marked bold (as "Startup project)  
# Make sure the "DarkModTools" project is marked bold (as "Startup project")  
# Compile and hit run (F5), Studio will start your TheDarkMod.exe and attach automatically
# Compile and hit run (F5), Studio will start your TheDarkMod.exe and attach automatically


Line 41: Line 48:
# Once the game is up and running, Alt-Tab back to Visual Studio
# Once the game is up and running, Alt-Tab back to Visual Studio
# Go to menu "Debug" > "Attach to Process..." and select the TheDarkMod.exe process from the list in that dialog popping up.
# Go to menu "Debug" > "Attach to Process..." and select the TheDarkMod.exe process from the list in that dialog popping up.
# The debugger will now attach to TDM (along with all loaded DLLs) and you can now place breakpoints or intercept game crashes.
# The debugger will now attach to TDM and you can now place breakpoints or intercept game crashes.


=== Troubleshooting ===
=== Troubleshooting ===
Line 49: Line 56:
;I cannot inspect all the variables / The instruction pointer is skipping code
;I cannot inspect all the variables / The instruction pointer is skipping code
:You are probably running a release build, which comes with some optimisations. When debugging a release build, you'll notice that your instruction pointer (the yellow arrow) is sometimes skipping statements, which have most likely been optimised out of the binary during compilation/linking. You'll also have troubles when trying to inspect temporary variables or inlined functions. Use a debug build if this prevents you from figuring out things during debugging.
:You are probably running a release build, which comes with some optimisations. When debugging a release build, you'll notice that your instruction pointer (the yellow arrow) is sometimes skipping statements, which have most likely been optimised out of the binary during compilation/linking. You'll also have troubles when trying to inspect temporary variables or inlined functions. Use a debug build if this prevents you from figuring out things during debugging.
;Debugging works well, but the game plays too slowly
:You are running debug build, which is much slower than release. There are several ways to make life easier. First, you can get to the place where problem happens in release build and save your game there, then run debug build and load the game to do debugging. Second, you can try the "Debug with inlines" configuration, which is faster than full debug build, but is still very convenient to debug. If this is not fast enough for you, you can also debug the release build directly, but be aware that breakpoints and watches do not always work due to optimizations. Note that even release build is slower with debugger than without it because of debug heap. You can disable it by setting environment variable [https://ofekshilon.com/2014/09/20/accelerating-debug-runs-part-1-_no_debug_heap-2/ _NO_DEBUG_HEAP=1]. If you do it properly, then your release build should run with full speed.


== Linux ==
== Linux ==
You need GCC 5 or newer to build TDM on Linux.
Anything older than GCC 4.7 surely won't work.
Just as the original Doom 3, TDM is built using Scons build system.
Being in the source code root directory (darkmod_src/), you can build TDM with a command like this:
  scons BUILD="release" TARGET_ARCH="x64" -j6 ..
If you omit some parameters, Scons will either use the previously defined values or the default ones.
Here is the explanation of parameters:
* <tt>BUILD="release"</tt> --- build release (i.e. optimized) executable
* <tt>TARGET_ARCH="x64"</tt> --- build for 64-bit platform (pass "x86" or "x32" for 32-bit build)
* <tt>-j6</tt> --- run six instances of compiler in parallel for faster build (better specify the number of cores in your CPU)
* <tt>..</tt> --- put executables with debug information to ../darkmod (scons cannot access parent directory without it)
Run <tt>scons --help</tt> for more information about arguments.
Note: by default the deploy-ready executables are put into the current directory (which is source code root directory).
They are stripped of debug information, so you won't be able to debug them.
If you need debug information, make sure to specify "<tt>..</tt>" argument: then debuggable executables will be put into ../darkmod.
Note: starting from version 2.06, fully functional 64-bit build is supported.
=== Ubuntu 16.04 ===
The simplest approach is to do a native build, i.e. produce 64-bit binaries on 64-bit OS, or 32-bit binaries on 32-bit OS.
Starting from a clean Ubuntu installation, here is the list of packages you need to install:
  sudo apt-get install scons                    //'scons' is currently not installed
  sudo apt-get install m4                      //'SCons Environment' object has no attribute 'M4'
  sudo apt-get install subversion              //svnversion: not found
  sudo apt-get install mesa-common-dev          //no such file: "Gl/gl.h"
  sudo apt-get install libxxf86vm-dev          //no such file: "X11/extensions/xf86vmode.h"
  sudo apt-get install libopenal-dev            //no such file: "AL/al.h"
  sudo apt-get install libxext-dev              //no such file: "X11/extensions/Xext.h"
After that you can run scons build with one of the commands:
  scons BUILD="release" TARGET_ARCH="x86" ..    //on 32-bit OS
  scons BUILD="release" TARGET_ARCH="x64" ..    //on 64-bit OS
If you have 64-bit Linux, you can also build and run 32-bit TDM.
Note that this approach is slightly more complicated.
You have to install the following packages in addition to the ones listed above:
  sudo apt-get install g++-multilib            //no such file: 'sys/cdefs.h'
  sudo apt-get install libx11-dev:i386          //cannot find "-lX11"
  sudo apt-get install libxxf86vm-dev:i386      //cannot find "-lXxf86vm"
  sudo apt-get install libopenal-dev:i386      //cannot find "-lopenal"
  sudo apt-get install libxext-dev:i386        //cannot find "-lXext"
Then run build as usual:
  scons BUILD="release" TARGET_ARCH="x86" ..
The 64-bit and 32-bit versions can be built independently on a single 64-bit Linux.
=== Other distros ===
Even if you have Linux distro different from Ubuntu, the instructions above will most likely help you.
If you have still have problems with your build, please report to forums.
== I have a bugfix for the team ==
In case you figured out a problem in the TDM game code and you maybe even have a fix available, please drop by at our forums to tell the coding staff. Your fix might be incorporated in the main development branch.
== Working in SVN ==
If you work directly with [https://svn.thedarkmod.com/svn/darkmod_src/trunk SVN], make sure that [http://svnbook.red-bean.com/en/1.7/svn.ref.svnversion.re.html svnversion] command works properly in OS console:
* ''Windows'': install TortoiseSVN with "command line client tools" included.
* ''Linux'': install "subversion" package.
To check that it works, build TDM yourself, run it, and then open TDM console. You should see the correct SVN revision number in the lower-right corner.
== Dead text below ==
The remaining part of the article is most likely outdated and does not apply to version 2.06 (and later).
It would be probably better to simply delete it. Feel free to expand and do history digging if you like.
<div class="toccolours mw-collapsible mw-collapsed" style="width:100%; overflow:auto;>
''' Linux '''


For Linux you'll need gcc and scons, plus a few packages depending on your distribution. There is a README.linux file contained in the source package you downloaded, check it out for some details.
For Linux you'll need gcc and scons, plus a few packages depending on your distribution. There is a README.linux file contained in the source package you downloaded, check it out for some details.


=== Debian Sqeeze 64 bit ===
''' Debian Sqeeze 64 bit '''


You need the following packages:
You need the following packages:
Line 80: Line 172:
  ln -s /lib32/libpng12.so.0 /lib32/libpng.so
  ln -s /lib32/libpng12.so.0 /lib32/libpng.so


=== Ubuntu 10.10 64 Bit ===
''' Ubuntu 10.10 64 Bit '''
 
You'll need the same packages as for the 32 bit Ubuntu variants, plus a few additional 32 bit compatibility packages (ia32-libs and libc6-dev-i386):
You'll need the same packages as for the 32 bit Ubuntu variants, plus a few additional 32 bit compatibility packages (ia32-libs and libc6-dev-i386):
  sudo apt-get install g++ scons libglew1.5-dev libpng12-dev libjpeg62-dev ia32-libs libc6-dev-i386
  sudo apt-get install g++ scons libglew1.5-dev libpng12-dev libjpeg62-dev ia32-libs libc6-dev-i386
Line 86: Line 179:
  scons BUILD="release" BUILD_GAMEPAK="1"
  scons BUILD="release" BUILD_GAMEPAK="1"


=== Ubuntu 10.04 32 Bit ===
''' Ubuntu 10.04 32 Bit '''
 
After setting up a clean 10.04, these are the packages needed to get the source to compile. Copy & paste the following line:
After setting up a clean 10.04, these are the packages needed to get the source to compile. Copy & paste the following line:
  sudo apt-get install g++ scons libglew1.5-dev libpng12-dev libjpeg62-dev
  sudo apt-get install g++ scons libglew1.5-dev libpng12-dev libjpeg62-dev
Line 95: Line 189:
That should install all packages needed.
That should install all packages needed.


== Mac OS X ==
''' Mac OS X '''
 
For OS X you'll need gcc and scons, as with Linux. gcc should be included in your xcode installation, scons can be downloaded from the [http://www.scons.org/ scons project website]. The third-party libraries like boost, devil and libcurl are already included in the TDM source package, so it should compile out of the box. If you ever need to build one of them from scratch, see the subsections below.
For OS X you'll need gcc and scons, as with Linux. gcc should be included in your xcode installation, scons can be downloaded from the [http://www.scons.org/ scons project website]. The third-party libraries like boost, devil and libcurl are already included in the TDM source package, so it should compile out of the box. If you ever need to build one of them from scratch, see the subsections below.


The sconscripts are prepared for both Intel and PPC target architectures, the MACOSX_TARGET_ARCH argument will control which architecture you're compiling for.
The sconscripts are prepared for both Intel and PPC target architectures, the MACOSX_TARGET_ARCH argument will control which architecture you're compiling for.


=== Compiling for Intel architecture ===
''' Compiling for Intel architecture '''
 
To start compiling, enter the following command in the folder you extracted the TDM sources to:
To start compiling, enter the following command in the folder you extracted the TDM sources to:
  scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="i386"
  scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="i386"


=== Compiling for PPC architecture ===
''' Compiling for PPC architecture '''
 
To start compiling, enter the following command in the folder you extracted the TDM sources to:
To start compiling, enter the following command in the folder you extracted the TDM sources to:
  scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="ppc"
  scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="ppc"


=== Compiling a universal binary ===
''' Compiling a universal binary '''
 
I've been using the following script to generate a universal binary. This script assumes that there are two separate TDM source folders, one in <tt>darkmod_src.i386</tt> and one in <tt>darkmod_src.ppc</tt>.  
I've been using the following script to generate a universal binary. This script assumes that there are two separate TDM source folders, one in <tt>darkmod_src.i386</tt> and one in <tt>darkmod_src.ppc</tt>.  
Note: they are actual copies of the same TDM source package, I just used that as convenience such that I don't have to recompile the whole source tree after minor changes.
Note: they are actual copies of the same TDM source package, I just used that as convenience such that I don't have to recompile the whole source tree after minor changes.
Line 124: Line 222:
After this the <tt>darkmod_src.i386/tdm_game03.pk4</tt> should contain the universal binary of the TDM game lib. The PK4 is about 6 to 7 MB.
After this the <tt>darkmod_src.i386/tdm_game03.pk4</tt> should contain the universal binary of the TDM game lib. The PK4 is about 6 to 7 MB.


=== Installing scons ===
''' Installing scons '''
 
Get the scons tarball from their website, unpack it to a folder and run the following commands (note that the exact scons version might differ):
Get the scons tarball from their website, unpack it to a folder and run the following commands (note that the exact scons version might differ):
  cd scons-2.0.1
  cd scons-2.0.1
  python setup.py install
  python setup.py install


=== Building libcurl in Mac OS X ===
''' Building libcurl in Mac OS X '''
 
Download the libcurl 7.21 source package, and extract it on your system. To produce a so-called "fat" binary you need to compile for both i386 and ppc targets.
Download the libcurl 7.21 source package, and extract it on your system. To produce a so-called "fat" binary you need to compile for both i386 and ppc targets.


Line 154: Line 254:
The filesize of the newly created <tt>libcurl.a</tt> should be around the sum of the single ppc and i386 libs, you can double-check that. Copy the <tt>libcurl.a</tt> into your <tt>darkmod_src/macosx/libcurl/</tt> and you're done with this step.
The filesize of the newly created <tt>libcurl.a</tt> should be around the sum of the single ppc and i386 libs, you can double-check that. Copy the <tt>libcurl.a</tt> into your <tt>darkmod_src/macosx/libcurl/</tt> and you're done with this step.


=== Building Boost static libs in Mac OS X ===
''' Building Boost static libs in Mac OS X '''


Download the boost 1.45 sources and extract them to your hard drive. Create a jam user config file to use the g++ 4.0 compiler instead of the default gcc 4.2 in Leopard: create a new file in your boost root folder and name it <tt>user-config-darwin.jam</tt>:
Download the boost 1.45 sources and extract them to your hard drive. Create a jam user config file to use the g++ 4.0 compiler instead of the default gcc 4.2 in Leopard: create a new file in your boost root folder and name it <tt>user-config-darwin.jam</tt>:
Line 174: Line 274:
Copy all libboost*.a files to <tt>darkmod_src/macosx/boost/lib/</tt>.
Copy all libboost*.a files to <tt>darkmod_src/macosx/boost/lib/</tt>.


== I have a bugfix for the team ==
</div>
In case you figured out a problem in the TDM game code and you maybe even have a fix available, please drop by at our forums to tell the coding staff. Your fix might be incorporated in the main development branch.
 
== Additional Info about the TDM Code ==
The Dark Mod codebase is quite large in the meantime and we have reorganised and refactored/replaced a number of things. There are a few things which haven't changed too much (like the animation code), but most gameplay code has been altered to fit TDM's needs.
 
Additionally, the TDM code relies on a few static libraries which are not required in the vanilla D3 code, see below.
 
=== Boost Libraries ===
TDM's code is using [http://www.boost.org boost] libraries. Most boost libraries we're using are header-only (i.e. they work without special linking), with the exception of filesystem, system, threads, program_options etc. The latter ones require a static library to be built for your OS and linked into the game code. For Windows the TDM source package you downloaded already contains the correct binaries for VC++ 2005 (7-zipped), VC++ 2008 and VC++ 2010 in both release and debug flavours. They can be found in the win32\lib folder.
 
=== ZipLoader ===
For the FM installation code, we made use of the minizip/zlib sources. For Windows and Linux the package already comes with the correct static .lib and .a files, so this should work out of the box. In case you need to compile these libraries from scratch (e.g. for a newer compiler or a different OS) there is a .vcproj file available in win32\ziploader (Windows) or a sconscript in <tt>sys/scons/Sconscript.ziploader</tt>. Use these to compile a new static library and make sure the library is referenced by the d3game project.
 
=== DevIL ===
Our lightgem code makes use of some image processing routines, which are contained in the open source DevIL package. The correct static library is already contained in the source package you downloaded, hence it should work right out of the box. In case you need to compile that library from scratch (applies to Windows only, Linux users will just need to download the correct package from their repositories), there are the DevIL sources in win32/devil, including a vcproj file, which you can use as basis.
 
== How to compile the boost static libraries in Windows ==
See also the main article: [[Compile the static Boost Libraries in Windows]]
 
Any VC++ compiler version '''other than VC++ 2013''' will require a recompile of the boost static libraries which The Dark Mod links against. At the time of writing, TDM is using the following boost libraries:
* boost.filesystem
* boost.system
* boost.thread
* boost.date_time
* boost.regex (for the updater/pakager)
* boost.program_options (for the updater/packager)


Now take the *.lib files and copy them into your '''win32/lib''' folder in your source directory and the linking should succeed.


[[Category:Tutorial]]
[[Category:Tutorial]]
[[Category:Coding]]
[[Category:Coding]]

Revision as of 16:54, 21 May 2018

Intended article audience: engine coders

This guide should provide you with enough information to compile The Dark Mod's game code from source. It applies to version 2.06 or later version of TDM. If you want to compile older version, see the history of this wiki page. Brief compilation instructions are also included in COMPILING.txt file in the source code package.

The sources are available through "snapshots", i.e. whenever the Dark Mod team is releasing a new update (e.g. TDM 2.06) the corresponding sources are released as well.

Get the sources

Be warned though that (unless you're a team member and working on the SVN asset base) these sources might be incompatible with your local darkmod installation. The team cannot and will not support you in case you're running into troubles trying to get it to run.

Download the sources and unpack them next to your darkmod/ directory, such that the directory structure looks like this:

C:\Games\Doom3\darkmod       <-- your darkmod location
C:\Games\Doom3\darkmod_src   <-- your source folder containing the solution, can be renamed

This directory structure is recommended for both Windows and Linux.

Windows

Since TDM 2.03 you'll need Visual Studio 2013 to compile the project. The free Community Edition works fine, it can be downloaded approximately here. Additionally, you have to:

You'll find a TheDarkMod.sln solution file (in MSVC 2013 format) in the source code folder, which you can double-click to open in Visual Studio. The solution is designed to put the compiled binaries into the ../darkmod folder nearby, that's why we recommend using the directory layout shown above. (You can change the output paths in the property sheets, in case you know how to do that).

Once the solution is opened, select the Configuration in the topmost toolbar (either "release" or "debug", depending on what you want to do) and Platform (either Win32 or x64). Then hit "Build Solution" (Ctrl-Shift-B or F7). The compilation usually takes a minute or two, watch the output window at the bottom of Visual Studio. After completion you'll find the compiled binary in your darkmod/ folder. It would be either TheDarkMod.exe or TheDarkModx64.exe, depending on the target platform you chose.

The code uses DirectInput, which is automatically installed with VS2013 as a part of Windows SDK. Normally, you don't have to do anything about it. But if you have trouble with DirectInput, you can download the deprecated "Microsoft DirectX SDK" here. In such case you will have to manually add paths to DirectX SDK to the property sheets.

Debugging the Engine/Game

To debug your custom built code, you need to attach Visual Studio's debugger to the TheDarkMod.exe process. There are two ways to accomplish that:

The quick one:

  1. Go to Visual Studio and open the TheDarkMod solution
  2. Make sure the "DarkModTools" project is marked bold (as "Startup project")
  3. Compile and hit run (F5), Studio will start your TheDarkMod.exe and attach automatically

The manual way:

  1. Start your custom TheDarkMod.exe through Windows Explorer or shortcuts
  2. Once the game is up and running, Alt-Tab back to Visual Studio
  3. Go to menu "Debug" > "Attach to Process..." and select the TheDarkMod.exe process from the list in that dialog popping up.
  4. The debugger will now attach to TDM and you can now place breakpoints or intercept game crashes.

Troubleshooting

My breakpoints don't work (they are hollow circles instead of full ones)
Make sure you're attached to the correct TheDarkMod.exe binary. If you're attaching to an older version (e.g. from an outdated compilation process) or one you haven't built in Studio yourself, VC++ won't be able to load the symbols from the .pdb files. Make sure that the configuration type (release or debug build) is matching as well.
I cannot inspect all the variables / The instruction pointer is skipping code
You are probably running a release build, which comes with some optimisations. When debugging a release build, you'll notice that your instruction pointer (the yellow arrow) is sometimes skipping statements, which have most likely been optimised out of the binary during compilation/linking. You'll also have troubles when trying to inspect temporary variables or inlined functions. Use a debug build if this prevents you from figuring out things during debugging.
Debugging works well, but the game plays too slowly
You are running debug build, which is much slower than release. There are several ways to make life easier. First, you can get to the place where problem happens in release build and save your game there, then run debug build and load the game to do debugging. Second, you can try the "Debug with inlines" configuration, which is faster than full debug build, but is still very convenient to debug. If this is not fast enough for you, you can also debug the release build directly, but be aware that breakpoints and watches do not always work due to optimizations. Note that even release build is slower with debugger than without it because of debug heap. You can disable it by setting environment variable _NO_DEBUG_HEAP=1. If you do it properly, then your release build should run with full speed.

Linux

You need GCC 5 or newer to build TDM on Linux. Anything older than GCC 4.7 surely won't work. Just as the original Doom 3, TDM is built using Scons build system.

Being in the source code root directory (darkmod_src/), you can build TDM with a command like this:

 scons BUILD="release" TARGET_ARCH="x64" -j6 ..

If you omit some parameters, Scons will either use the previously defined values or the default ones.

Here is the explanation of parameters:

  • BUILD="release" --- build release (i.e. optimized) executable
  • TARGET_ARCH="x64" --- build for 64-bit platform (pass "x86" or "x32" for 32-bit build)
  • -j6 --- run six instances of compiler in parallel for faster build (better specify the number of cores in your CPU)
  • .. --- put executables with debug information to ../darkmod (scons cannot access parent directory without it)

Run scons --help for more information about arguments.

Note: by default the deploy-ready executables are put into the current directory (which is source code root directory). They are stripped of debug information, so you won't be able to debug them. If you need debug information, make sure to specify ".." argument: then debuggable executables will be put into ../darkmod.

Note: starting from version 2.06, fully functional 64-bit build is supported.

Ubuntu 16.04

The simplest approach is to do a native build, i.e. produce 64-bit binaries on 64-bit OS, or 32-bit binaries on 32-bit OS. Starting from a clean Ubuntu installation, here is the list of packages you need to install:

 sudo apt-get install scons                    //'scons' is currently not installed
 sudo apt-get install m4                       //'SCons Environment' object has no attribute 'M4'
 sudo apt-get install subversion               //svnversion: not found
 sudo apt-get install mesa-common-dev          //no such file: "Gl/gl.h"
 sudo apt-get install libxxf86vm-dev           //no such file: "X11/extensions/xf86vmode.h"
 sudo apt-get install libopenal-dev            //no such file: "AL/al.h"
 sudo apt-get install libxext-dev              //no such file: "X11/extensions/Xext.h"

After that you can run scons build with one of the commands:

 scons BUILD="release" TARGET_ARCH="x86" ..    //on 32-bit OS
 scons BUILD="release" TARGET_ARCH="x64" ..    //on 64-bit OS

If you have 64-bit Linux, you can also build and run 32-bit TDM. Note that this approach is slightly more complicated. You have to install the following packages in addition to the ones listed above:

 sudo apt-get install g++-multilib             //no such file: 'sys/cdefs.h'
 sudo apt-get install libx11-dev:i386          //cannot find "-lX11"
 sudo apt-get install libxxf86vm-dev:i386      //cannot find "-lXxf86vm"
 sudo apt-get install libopenal-dev:i386       //cannot find "-lopenal"
 sudo apt-get install libxext-dev:i386         //cannot find "-lXext"

Then run build as usual:

 scons BUILD="release" TARGET_ARCH="x86" ..

The 64-bit and 32-bit versions can be built independently on a single 64-bit Linux.

Other distros

Even if you have Linux distro different from Ubuntu, the instructions above will most likely help you. If you have still have problems with your build, please report to forums.

I have a bugfix for the team

In case you figured out a problem in the TDM game code and you maybe even have a fix available, please drop by at our forums to tell the coding staff. Your fix might be incorporated in the main development branch.

Working in SVN

If you work directly with SVN, make sure that svnversion command works properly in OS console:

  • Windows: install TortoiseSVN with "command line client tools" included.
  • Linux: install "subversion" package.

To check that it works, build TDM yourself, run it, and then open TDM console. You should see the correct SVN revision number in the lower-right corner.

Dead text below

The remaining part of the article is most likely outdated and does not apply to version 2.06 (and later). It would be probably better to simply delete it. Feel free to expand and do history digging if you like.

Linux

For Linux you'll need gcc and scons, plus a few packages depending on your distribution. There is a README.linux file contained in the source package you downloaded, check it out for some details.

Debian Sqeeze 64 bit

You need the following packages:

apt-get install ia32-libs scons g++ g++-multilib m4 zip
apt-get install libglew1.5-dev libpng12-dev libjpeg62-dev
apt-get install libc6-dev-i386 libxxf86vm-dev libopenal-dev libasound2-dev libxext-dev

You must also edit sys/scons/SConscript.game and add the following lines near where local_env.Append is alread used:

local_env.Append(LIBS = [
       File('/lib32/libpng12.so.0'),
])

Also change in the same file (a few lines above):

local_env.Append( LINKFLAGS = [ '-lrt', '-lpng' ] )

to:

local_env.Append( LINKFLAGS = [ '-lrt', '-lpng12' ] )

It might also be necessary to make the following symlink:

ln -s /lib32/libpng12.so.0 /lib32/libpng.so

Ubuntu 10.10 64 Bit

You'll need the same packages as for the 32 bit Ubuntu variants, plus a few additional 32 bit compatibility packages (ia32-libs and libc6-dev-i386):

sudo apt-get install g++ scons libglew1.5-dev libpng12-dev libjpeg62-dev ia32-libs libc6-dev-i386

Then just run the scons command to start compiling:

scons BUILD="release" BUILD_GAMEPAK="1"

Ubuntu 10.04 32 Bit

After setting up a clean 10.04, these are the packages needed to get the source to compile. Copy & paste the following line:

sudo apt-get install g++ scons libglew1.5-dev libpng12-dev libjpeg62-dev

Then run this command to start compiling:

./linuxBuild.sh

If the build fails, complaining that it can't find something, it needs more libraries. Execute the following line:

sudo apt-get install m4 libxxf86vm-dev libopenal-dev libasound2-dev g++-multilib gcc-multilib zlib1g-dev libxext-dev

That should install all packages needed.

Mac OS X

For OS X you'll need gcc and scons, as with Linux. gcc should be included in your xcode installation, scons can be downloaded from the scons project website. The third-party libraries like boost, devil and libcurl are already included in the TDM source package, so it should compile out of the box. If you ever need to build one of them from scratch, see the subsections below.

The sconscripts are prepared for both Intel and PPC target architectures, the MACOSX_TARGET_ARCH argument will control which architecture you're compiling for.

Compiling for Intel architecture

To start compiling, enter the following command in the folder you extracted the TDM sources to:

scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="i386"

Compiling for PPC architecture

To start compiling, enter the following command in the folder you extracted the TDM sources to:

scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="ppc"

Compiling a universal binary

I've been using the following script to generate a universal binary. This script assumes that there are two separate TDM source folders, one in darkmod_src.i386 and one in darkmod_src.ppc. Note: they are actual copies of the same TDM source package, I just used that as convenience such that I don't have to recompile the whole source tree after minor changes.

cd /Users/greebo
cd darkmod_src.i386
scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="i386"
cd ../darkmod_src.ppc
scons BUILD="release" BUILD_GAMEPAK="1" MACOSX_TARGET_ARCH="ppc"
cd ../darkmod_src.i386
lipo -arch i386 gamei386-base.dylib -arch ppc ../darkmod_src.ppc/gameppc-base.dylib -create -output game.dylib
zip -d tdm_game03.pk4 game.dylib
zip tdm_game03.pk4 game.dylib

After this the darkmod_src.i386/tdm_game03.pk4 should contain the universal binary of the TDM game lib. The PK4 is about 6 to 7 MB.

Installing scons

Get the scons tarball from their website, unpack it to a folder and run the following commands (note that the exact scons version might differ):

cd scons-2.0.1
python setup.py install

Building libcurl in Mac OS X

Download the libcurl 7.21 source package, and extract it on your system. To produce a so-called "fat" binary you need to compile for both i386 and ppc targets.

Build the i386 target by entering:

env CFLAGS="-m32 -arch i386" LDFLAGS="-m32 -arch i386" ./configure --disable-ldap --build=i686-unknown-linux-gnu --without-libidn --without-zlib --without-ssl
make
sudo make install

After make install the static library can be found in /usr/local/lib/libcurl.a, copy that file to your curl folder and rename it to ./libcurl.i386.a

Build the powerpc target by entering:

env CFLAGS="-m32 -arch ppc" LDFLAGS="-m32 -arch ppc" ./configure --disable-ldap --build=powerpc-unknown-linux-gnu --without-libidn --without-zlib --without-ssl
make
sudo make install

After make install the static library can be found in /usr/local/lib/libcurl.a, copy that file to your curl folder and rename it to ./libcurl.ppc.a

Finally call lipo to combine these two into a fat binary by entering this in your curl folder.

lipo -arch i386 libcurl.i386.a -arch ppc libcurl.ppc.a -create -output libcurl.a

The filesize of the newly created libcurl.a should be around the sum of the single ppc and i386 libs, you can double-check that. Copy the libcurl.a into your darkmod_src/macosx/libcurl/ and you're done with this step.

Building Boost static libs in Mac OS X

Download the boost 1.45 sources and extract them to your hard drive. Create a jam user config file to use the g++ 4.0 compiler instead of the default gcc 4.2 in Leopard: create a new file in your boost root folder and name it user-config-darwin.jam:

using darwin : 8.11 : /usr/bin/g++-4.0 :
    <architecture>"combined"
    <address-model>"32"
    <macosx-version>"10.4"
    <macosx-version-min>"10.4"
    <link>"static"
    <threading>"multi" ;

Download a bjam binary for OS X to your machine, then build boost threads, filesystem and system:

/path/to/bjam --user-config=../../../user-config-darwin.jam architecture=combined link=static threading=multi address-model=32 release [stage]

The "stage" option only works in filesystem and system (not in thread, as of boost 1.45). You'll find the filesystem and system libs in the ./stage folder of your boost root, the libboost_thread.a will be located in the bin.v2 folder after compilation.

Copy all libboost*.a files to darkmod_src/macosx/boost/lib/.