DarkRadiant - Compilation Guide

From The DarkMod Wiki
Jump to navigationJump to search

DarkRadiant's codebase is open source. To compile the sources you can either use

  • Windows: Visual C++ 2015 Community Edition (higher editions also possible: Professional, Ultimate, ...)
  • Linux: gcc/g++.

All compilers can be acquired for free and should be able to produce 32 Bit and 64 Bit builds. In any case, since DarkRadiant is using part of the C++11 feature set, a compiler supporting the C++11 standard is required.

Use Git

The main codebase is stored and maintained on github[1], you'll therefore need some Git client like

Windows users: Download and install the git client, into any folder of your preference. After installation it might ask to reboot your machine, as Tortoise integrates into the Explorer shell.

Clone the Sources

Windows users (github:windows): Create your github-login, configure github:windows as desired, especially the target-workingfolder, which may not contain any spaces. Browse to the github-page of DarkRadiant and click on Clone in Windows]. That's it!

Windows users (Tortoise): To prepare the source download, open Windows Explorer and create the folder you want to clone (i.e. download) the sources into. Make sure the folder does not contain spaces. Use your Git client to clone the DarkRadiant repository from github:

Dr git clone.png

Linux users: The git command line equivalent would be this:

git clone git://github.com/codereader/DarkRadiant.git

Cloning takes a minute or two - after the process is finished your folder should be looking like this:

Dr bare repo.png

Windows users: this is not yet enough to compile DarkRadiant in Windows, you still need to download and extract the dependencies, see the next step. Linux people: proceed directly to the Linux compilation article.

Windows: Download the Dependencies

For Windows builds additional dependencies must be downloaded and copied into the source tree. To keep the github source repository small, the dependencies can be downloaded as 7-zipped packages (you can get 7-zip here):

https://github.com/codereader/DarkRadiant/releases/download/2.1.0/w32deps.7z
https://github.com/codereader/DarkRadiant/releases/download/2.1.0/w64deps.7z (needed for x64 builds)

If you're in Windows 7 x64 (or any higher 64 bit Windows version) you need to download both packages. Download and extract them directly to the directory you cloned the sources to. The resulting folder structure should look like this.

Dr windeps repo.png

Important: The w32deps/ (or w64deps/) folder must be in the same folder as the radiant/ or include/ folder.

Compilation

Once you've downloaded the sources, the steps for compiling DarkRadiant depend on your toolset/compiler. Choose one of the links below:

Advanced Users: Compiling the Windows Dependencies

Boost static libraries

Any VC++ compiler version other than the ones mentioned above will require a recompile of the boost static libraries which DarkRadiant links against. At the time of writing, DarkRadiant is using the following boost libraries:

  • boost.filesystem
  • boost.regex
  • boost.system
  • boost.python

Go get the boost sources from their website (http://www.boost.org) and extract them into a new folder. To build the required static libraries, boost provides the bootstrap script which generates the b2.exe file for you.

Prepare for building boost.python

I found it's necessary to have both the x86 and x64 variants of Python 2.6 installed to compile the boost.python library for both 32 and 64 bit platforms. Get the x86 and x64 installer from the Python website and install them. The experience isn't a very smooth one, I ended up adding the include/ and lib/ folders of the respective Python installation to my PATH environment variable (when targeting the x64 platform, I have the corresponding include/ folder from the Python 2.6 x64 installation in my path, and for the x86 build I need to change them before starting the next build process).

I also added the following lines to my project-conf.jam file which is created in the boost root folder by bootstrap.bat. This is said to help boost to find the Python include files, but I'm not entirely sure if this is necessary:

using python : 2.6 : C:\\Python26 ;
using python : 2.6 : C:\\Python26x64 :  :  : <address-model>64 ;

Use DarkRadiant's build scripts

I prepared some batch files which do most of the dirty work for you. As prerequisite make sure that the path to bjam.exe is added to your PATH before invoking the scripts.

  • Open a "Developer Command Prompt for VS2015" (from your Start menu)
  • Change directories to the folder where you extracted the downloaded boost package to, e.g. c:\downloads\boost_1_61_0
  • Run the build scripts from there, e.g. c:\games\darkradiant\tools\scripts\build_boost_libs, assuming that the DarkRadiant SVN trunk has been checked out to c:\games\darkradiant.
  • Copy the files from the stage/ folder (which just popped up as a new Explorer window) to your w32deps/boost/libs folder.
  • [64 Bit Build]: Use the build_boost_libs.x64 batch file to build the x64 libraries, but beware that this will overwrite the current contents of the stage/ folder.

Build a boost library manually

See main article: Compile the static Boost Libraries in Windows

The *.lib files from the stage/ folder should be copied into your w32deps/boost/lib folder (or the w64deps/boost/lib for Win64 targets) in your darkradiant directory and the linking should succeed.

Compile the support libraries needed by DR

DarkRadiant is using a lot of third-party libraries like libxml2, libiconv, vorbis, etc.

For Windows I set up custom VC++ solutions to compile most of the libraries directly from the source (as many of those third-party projects don't offer Windows x64 binaries), these projects can be found in the trunk/winbuild branch in SVN. The winbuild folder contains all the sources needed to build the Win32/Win64 dependency binaries. Note that the headers are stored in w32deps, as the main DarkRadiant project needs them there, so w32deps is the place to look for most of the shared headers.

There are VC++ project files in the msvc2015 folder which work best when the winbuild folder is checked out as subfolder to the trunk/darkradiant working copy, next to your w32deps/w64deps directories, as indicated above. To check out the winbuild folder:

  1. Right-click your C:\Games folder >> SVN Checkout...
  2. Select https://svn.code.sf.net/p/darkradiant/code/trunk/winbuild to C:\Games\DarkRadiant\winbuild

The folder structure should then look like this:

C:\Games\DarkRadiant
C:\Games\DarkRadiant\w32deps
C:\Games\DarkRadiant\w64deps [optional for x64 builds]
C:\Games\DarkRadiant\winbuild

This way, the VC++ projects place their binaries in the correct location in the w32deps/w64deps folder and you can compile DarkRadiant right off the bat.

Program Database Files (.pdb)

When debugging a DarkRadiant crashdump, you'll need the program database files to get substantial information out of it, so it's vital to save the .pdb files right after compilation, otherwise they won't match against the signatures in the crashdump.

As far as the w32deps/w64deps dependencies are concerned, I've zipped up all the .pdb files and stored them on the FTP:

Notes

  1. The win32 and win64 dependencies are maintained in SVN at SourceForge, but you won't need to check out those unless you're a Windows developer and want to work on the Windows dependencies. If anything substantial changes within these they are zipped and uploaded to github's release area. Linux folks don't need these at all.