DarkRadiant - Compiling in Windows

From The DarkMod Wiki
Revision as of 06:41, 23 July 2017 by Greebo (talk | contribs) (Updates for 2.3.0 release)
Jump to: navigation, search

To compile the sources in Windows you will need Visual Studio 2017 Community Edition or higher. The Community Edition can be acquired for free and is able to produce both 32 Bit and 64 Bit builds.

You will need a Git client to clone the sources to your machine and install the Windows dependencies package. Then you're set up to compile DarkRadiant in Visual Studio.

Install a Git Client

The main codebase is stored and maintained on github, therefore you'll need a Git client like

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.

Download Sources and Dependencies

Using Github Desktop

Create your github-login, configure github desktop as desired, especially the default clone path in the options dialog. Browse to the github page of DarkRadiant and click on Clone in Windows. That's it!

Using TortoiseGit

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

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

Dr bare repo.png

This is not yet enough to compile DarkRadiant in Windows, you still need to download and extract the dependencies, see the next step.

Download the Dependencies Package

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):


Download and extract it directly to the directory you cloned the sources to. The resulting folder structure should look like this.

Dr windeps repo.png

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


Start Visual Studio and open the DarkRadiant solution file (.sln) which is ready for you in the tools/msvc folder.

To build a package for the x64 target, make sure to select the x64 platform from the configuration manager's dropdown box (located in Visual Studio's toolbar). If you prefer a 32 bit build, select the Win32 target.

Select release build (unless you want to debug a problem) and hit Ctrl-Shift-B in VC++ to start building the sources or select "Build > Build Solution" from the menus.


If you cloned the sources to C:\Games\DarkRadiant, the application binary will be placed in C:\Games\DarkRadiant\install\DarkRadiant.exe

The project output files are set up in a way to automatically install the binaries in the install/, install/modules/ and install/plugins/ folders. Also, all dependencies from the w32deps/ folder (see previous section) are automatically copied to the install/ folder during the post-build event. If anything goes wrong during compilation, please seek help in the forums.

The build expects the w32deps folder to be located alongside the sources, especially x64 builds expect the w64deps folder to be sitting next to it. See above for how to set up the folders in case you missed that step. For both platforms the output will be placed in the same install/ directory.

(Optional) Compiling the Windows Dependencies

This step is optional and more advanced. You won't need to do this if you just want to compile and run DarkRadiant using the currently maintained version of Visual Studio.

Boost static libraries

Any VC++ compiler version change (e.g. from VC++ 2017 to something newer) 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.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 possible to have both the x86 and x64 variants of Python around on your system 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 into separate target folders. I tried this with Python 3.6, so your mileage might vary.

Create a user-config.jam file and put it into your user folder, that might be C:\Users\greebo, for instance. To compile the 32-bit boost.python libs, I used the user-config.jam below, with my Python 3.6 x86 installation sitting in D:\temp\Python36-32 (for the records, I did not let the Python installer add anything to the PATH environment variable):

using python 
    : 3.6                   # Version
    : D:\\temp\\Python36-32\\python.exe      # Python Path
    : D:\\temp\\Python36-32\\include         # include path
    : D:\\temp\\Python36-32\\libs            # lib path(s)
    : <define>BOOST_ALL_NO_LIB=1

The I opened the Visual Studio Developer Command Prompt, changed folder to where I extracted the boost package (e.g. d:\temp\boost1_64) and started building using this command:

b2.exe toolset=msvc variant=release,debug link=static threading=multi stage --with-python

This will place the 32-bit libraries in the stage folder, where you can pick them up. Boost will create variants with "python" as well as "python3" in their name, I found it's only necessary to copy the "python" ones.

Note: you can try adding the switch --debug-configuration to your b2 command line to see some info about what Python folder b2 is linking against.

For the x64 build, the user-config.jam is the same except for the different paths. I cleared up the bin.v2 folder before starting the build, otherwise b2 would refuse to build anything, thinking everything was up to date:

using python 
    : 3.6                   # Version
    : D:\\temp\\Python36-64\\python.exe      # Python Path
    : D:\\temp\\Python36-64\\include         # include path
    : D:\\temp\\Python36-64\\libs            # lib path(s)
    : <define>BOOST_ALL_NO_LIB=1

The b2 command line I ended up using was this:

b2.exe toolset=msvc variant=release,debug link=static threading=multi stage --with-python address-model=64

which placed the generated libraries in the stage folder just as above.

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

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 winbuild folder in Git. 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.

The VC++ project files can be found in the winbuild/msvc folder. To check out the repo, go ahead like this:

  1. Right-click your C:\Games folder >> Git Clone...
  2. Select https://github.com/codereader/DarkRadiant_WinDeps.git to C:\Games\DarkRadiant_WinDeps

or by using the git command line

  1. git clone https://github.com/codereader/DarkRadiant_WinDeps.git C:\Games\DarkRadiant_WinDeps

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 windeps dependencies are concerned, I've zipped up all the .pdb files and stored them on the GitHub release page:

See also / Links