DarkRadiant - Compiling in Windows: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
 
(32 intermediate revisions by 2 users not shown)
Line 1: Line 1:
To compile the sources in Windows you will need '''Visual Studio 2015 Community Edition''' or higher. The Community Edition can be acquired for free and is able to produce both 32 Bit and 64 Bit builds.  
To compile the sources in Windows you will need '''Visual Studio 2022 Community Edition''' or higher. The Community Edition can be acquired for free and is able to produce 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.
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 =
= Install a Git Client =
The main codebase is stored and maintained on github<sup>[[#windeps_svn_note|[1]]]</sup>, you'll therefore need a Git client like
The main codebase is stored and maintained on github, therefore you'll need a Git client like
* [http://windows.github.com/ '''Github Desktop''']
* [http://windows.github.com/ '''Github Desktop''']
* [http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git '''TortoiseGit''']  
* [http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git '''TortoiseGit''']  
* [https://www.sourcetreeapp.com/ '''Sourcetree''']


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 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.


= Downlaod Sources and Dependencies =  
= Download Sources and Dependencies =  


== Using Github Desktop ==
== Using Github Desktop ==
Create your github-login, configure github desktop as desired, especially the default clone path in the options dialog. Browse to the [https://github.com/codereader/DarkRadiant github page of DarkRadiant] and click on '''Clone in Windows''']. That's it!
Create your github-login, configure github desktop as desired, especially the default clone path in the options dialog. Browse to the [https://github.com/codereader/DarkRadiant github page of DarkRadiant] and click on '''Clone in Windows'''. That's it!


== Using TortoiseGit ==
== 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:
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:
Make sure the '''recursive''' flag is checked in the dialog.


[[Image:dr git clone.png|200px]]
[[Image:dr git clone.png|200px]]
Line 23: Line 26:


[[Image:Dr_bare_repo.png|200px]]
[[Image:Dr_bare_repo.png|200px]]
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 [http://www.7-zip.org 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 variant) 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.
[[Image:Dr_windeps_repo.png|200px]]
'''Important:''' The w32deps/ (or w64deps/) folder must be in the same folder as the radiant/ or include/ folder.


= Compile =
= Compile =
Start Visual Studio and open the DarkRadiant solution file (.sln) which is ready for you in the <tt>tools/msvc2015</tt> folder.
Start Visual Studio and open the DarkRadiant solution file (.sln) which is ready for you in the root of the repository.
 
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.
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.
Line 49: Line 36:
The project output files are set up in a way to automatically install the binaries in the <tt>install/</tt>, <tt>install/modules/</tt> and <tt>install/plugins/</tt> 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 [http://forums.thedarkmod.com/forum/51-darkradiant-feedback-and-development/ forums].
The project output files are set up in a way to automatically install the binaries in the <tt>install/</tt>, <tt>install/modules/</tt> and <tt>install/plugins/</tt> 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 [http://forums.thedarkmod.com/forum/51-darkradiant-feedback-and-development/ 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.
The build expects the windeps folder to be stored in the root of the source tree, it should be created automatically the first time a build is started. See below for how to set up the folders in case that step went wrong.
 
== See also / Links ==
* [[DarkRadiant - Compilation Guide]]
* [https://www.visualstudio.com/en-us/downloads Visual Studio 2015 Community Edition]


= (Optional) Compiling the Windows Dependencies =
== Manual Download of the Dependencies Package ==
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.
For Windows builds additional dependencies are automatically downloaded and copied into the source tree by the build steps in Visual Studio. If this fails for any reason, you'll have to download and extract the package yourself, either by executing the script in


== Boost static libraries ==
tools/scripts/download_windeps.ps1
Any VC++ compiler version change (e.g. from VC++ 2015 to VC++ 2017) 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 ==
or by downloading the 7-zipped packages from the following URL (you can [http://www.7-zip.org get 7-zip here]):
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 <tt>project-conf.jam</tt> 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:
https://github.com/codereader/DarkRadiant_WinDeps/releases/latest


using python : 2.6 : C:\\Python26 ;
Download and extract it directly to the directory you cloned the sources to. The resulting folder structure should look like this.  
using python : 2.6 : C:\\Python26x64 :  :  : <address-model>64 ;


=== Use DarkRadiant's build scripts ===
[[Image:Dr_windeps_repo.png|200px]]
I prepared some batch files which do most of the dirty work for you. As prerequisite make sure that the path to <tt>bjam.exe</tt> is added to your PATH before invoking the scripts.


* Open a "Developer Command Prompt for VS2015" (from your Start menu)
'''Important:''' The windeps/ folder must be in the same folder as the radiant/ or include/ folder.
* 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. <tt>c:\games\darkradiant\tools\scripts\build_boost_libs</tt>, 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 <tt>w32deps/boost/libs</tt> folder.
* [64 Bit Build]: Use the <tt>build_boost_libs.x64</tt> 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 ===
= (Optional) Compiling the Windows Dependencies =
See main article: [[Compile the static Boost Libraries in Windows]]
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.


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.
Note: in the past DarkRadiant was linking against a few boost libraries requiring static libraries, this is no longer the case since August 2017.


== Compile the support libraries ==
== Compile the support libraries ==
DarkRadiant is using a lot of third-party libraries like libxml2, libiconv, vorbis, etc.
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 <tt>trunk/winbuild</tt> 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.
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 <tt>winbuild</tt> folder in Git. The winbuild folder contains all the sources needed to build the x64 dependency binaries.


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:
The VC++ project files can be found in the winbuild/msvc folder. To check out the repo, go ahead like this:


# Right-click your C:\Games folder >> SVN Checkout...
# Right-click your C:\Games folder >> Git Clone...
# Select https://svn.code.sf.net/p/darkradiant/code/trunk/winbuild to C:\Games\DarkRadiant\winbuild
# Select https://github.com/codereader/DarkRadiant_WinDeps.git to C:\Games\DarkRadiant_WinDeps


The folder structure should then look like this:
or by using the git command line


C:\Games\DarkRadiant
# git clone https://github.com/codereader/DarkRadiant_WinDeps.git C:\Games\DarkRadiant_WinDeps
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) ==
== 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.
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:
As far as the windeps dependencies are concerned, I've zipped up all the .pdb files and stored them on the GitHub release page:


* VC++ 2015 - x86: https://github.com/codereader/DarkRadiant/releases/download/2.1.0/w32deps.pdbs.7z
* VC++ 2022: https://github.com/codereader/DarkRadiant_WinDeps/releases/latest (look for windeps.pdbs.7z)
* VC++ 2015 - x64: https://github.com/codereader/DarkRadiant/releases/download/2.1.0/w64deps.pdbs.7z


== Notes ==
== See also / Links ==
#  <span id="windeps_svn_note">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.</span>
* [[DarkRadiant - Compilation Guide]]
* [https://visualstudio.microsoft.com/downloads/ Visual Studio 2022 Community Edition]
* [[Save a Memory Dump for debugging Crashes|Information about recording crash dumps]]


{{coding}}
{{coding}}
{{darkradiant|sort=Compilation}}
{{darkradiant|sort=Compilation}}

Latest revision as of 19:35, 1 April 2022

To compile the sources in Windows you will need Visual Studio 2022 Community Edition or higher. The Community Edition can be acquired for free and is able to produce 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:

Make sure the recursive flag is checked in the dialog.

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

Compile

Start Visual Studio and open the DarkRadiant solution file (.sln) which is ready for you in the root of the repository.

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.

Note

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 windeps folder to be stored in the root of the source tree, it should be created automatically the first time a build is started. See below for how to set up the folders in case that step went wrong.

Manual Download of the Dependencies Package

For Windows builds additional dependencies are automatically downloaded and copied into the source tree by the build steps in Visual Studio. If this fails for any reason, you'll have to download and extract the package yourself, either by executing the script in

tools/scripts/download_windeps.ps1

or by downloading the 7-zipped packages from the following URL (you can get 7-zip here):

https://github.com/codereader/DarkRadiant_WinDeps/releases/latest

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

Important: The windeps/ folder must be in the same folder as the radiant/ or include/ folder.

(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.

Note: in the past DarkRadiant was linking against a few boost libraries requiring static libraries, this is no longer the case since August 2017.

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 x64 dependency binaries.

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