DarkRadiant - Compilation Guide: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(even more typos)
(moved stuff into separate articles)
Line 26: Line 26:
  C:\DarkRadiant\w32deps\    <<----- w32deps/ is next to the radiant/ folder
  C:\DarkRadiant\w32deps\    <<----- w32deps/ is next to the radiant/ folder


= Compiling using Visual C++ 2005 (recommended) =
= Compiling =
You'll need a working VC++ build environment to open and compile the DarkRadiant solution file. See below for instructions about how to setup VC++ 2005 Express: [[#Installing_Visual_C.2B.2B_2005_Express_Edition|Installing VC++ 2005 Express]]
Once you've downloaded the sources, the steps for compiling DarkRadiant depend on your toolset/compiler. Choose one of the links below:
* [[DarkRadiant - Compiling in Visual C++ 2008|Compiling in Visual C++ 2008]]
* [[DarkRadiant - Compiling in Visual C++ 2005|Compiling in Visual C++ 2005]]
* [[DarkRadiant - Compiling in MinGW|Compiling in MinGW]] (Note: MinGW is not supported anymore, this page is outdated)
* [[DarkRadiant - Compiling in Linux|Compiling in Linux]]


Once you have VC++ installed, there is a prefabricated solution file (.sln) ready for you in the '''tools/vcprojects''' folder. I created them using MS Visual C++ 2005 Express Edition, I can't say how older versions behave, but I suspect newer ones will work fine. Hit Ctrl-Shift-B in VC++ to start building the sources.
== How to compile the boost static libraries in Windows ==
 
The project output files are setup so that the binaries get automatically installed in the install/, modules/ and plugins/ folders. Also, all dependencies from the w32deps/ folder (see previous section) are automatically copied into the install/ folder during the post-build event.
 
See the previous section of how to checkout the sources.
svn co https://darkradiant.svn.sourceforge.net/svnroot/darkradiant/trunk/darkradiant/
 
Note: Visual C++ 2008 Express Edition will not work, as the boost libraries haven't been upgraded yet - the boost headers will throw some errors and the static libraries are not compatible either. Hence this is not yet suppported.
 
= Compiling under Windows (MinGW) =
You'll need to download these pieces of software (these are all free, you don't need to pay for anything):
* [http://tortoisesvn.tigris.org '''TortoiseSVN'''] for obtaining the sources
* [http://www.mingw.org/download.shtml '''MinGW'''] the actual compiler
* [http://www.activestate.com/store/activepython/download '''ActivePython'''] to run scons (other Python releases should work as well)
* [http://www.scons.org/download.php '''scons'''] to run the compilation scripts
 
== Step 1: Install the Tools ==
First, download and install '''TortoiseSVN'''. Nothing special here, just install it into any folder of your preference. After installation it probably will ask to reboot your machine, as Tortoise integrates into the Explorer shell. (You can do that later, when all the other components have been installed).
 
Second, install the compiler '''MinGW'''. Launch the setup and choose the package '''Current''', then be sure to check the box of the '''g++''' compiler. Choose '''Download and Install''' in the next steps and let setup do the rest.
 
Third, install the '''ActivePython''' interpreter, which is needed to run the SconScript. Nothing spectacular here as well. After Python has been installed, run the '''scons''' installer (version 0.96.1 and 0.97 work for sure, don't know about others). Reboot the machine, to make sure everything is properly set up.
 
=== Set the Path to the MinGW Compiler ===
If scons complains about gcc and g++ missing, you will have to add the path to the compiler to your PATH environment variable:
* Press '''Win-Break''' or right-click on "My Computer" and choose "Properties". Go to advanced and seek the button for the Environment Variables. I'm not sure if it's called like this, because I'm running a German version of WinXP, but the Window should be something like this:
 
[http://img117.imageshack.us/img117/8184/drenvironmenthh3.jpg http://img117.imageshack.us/img117/8184/drenvironmenthh3.th.jpg]
 
Look to the variable named "Path" in the lower part of the dialog and double click the property. A small window will pop-up containing the name and the value of the environment variable. You'll have to add the path to the '''MinGW\bin''' folder to the end of the long string:
;C:\MinGW\bin;
Be sure that a semicolon divides the newly added path from the previous ones, as I indicated above. A double semicolon won't hurt either, so if the above folder is matching to your installation, you can as well copy & paste it into that window. Close the dialogs by hitting OK, you're done with that. The next time you'll open a console the path should be functional. If not, please double-check your path for typos and/or post in the forums.
 
== Step 2: Compile the Sources ==
If you're finished downloading the sources, open up the console by pressing '''Win-R''' or click '''Start''' > '''Run...''', then type '''cmd''' and confirm.
Once the DOS box is there, head to the according source folder by typing
cd C:\DarkRadiant
or whatever your path is where you downloaded them. Now type:
scons BUILD="release"
and the sources should start to compile (in release mode).
 
It's likely that I forgot something here and you might get scons complaining about a missing compiler or something. In that case, please tell greebo to update this tutorial accordingly.
 
The time neede to compile DarkRadiant strongly depends on your CPU power and may take up to ten minutes for a release build (a debug build may take much longer for whatever reasons).
 
== Step 3: Run DarkRadiant ==
The readily compiled sources can be found in the '''install/''' folder beneath the DarkRadiant root (the folder you downloaded your sources to).
C:\DarkRadiant\install\darkradiant.exe
Just create a shortcut by dragging the exe somewhere to your desktop with right mouse button and choose to create a link there. There is also an icon file located in the same folder you can use for this link to make it looking more pleasant.
 
If you get an error during startup, please contact greebo, perhaps there is something missing in this tutorial.
 
= Compiling under Linux =
 
== Install Libraries and Tools ==
 
=== Ubuntu 7.04 ===
 
You'll need a bunch of packages to get DarkRadiant to compile without glitches. I can't remember all from the top of my head, I will try to complete this list during my next Linux setup, but don't hold your breath. These are the names as found in Ubuntu 7.04 (Feisty Fawn):
 
* g++
* gcc-4.1
* scons 0.96.93 (or higher)
* libboost-dev
* libboost-serialization-dev
* libboost-filesystem-dev
* libboost-regex-dev
* libglew-dev
* libgtk2.0-dev
* libglib2.0-dev (maybe installed with libgtk2.0-dev)
* libgtkglext1-dev
* libxml2-dev
* libopenal-dev
* libalut-dev
* libvorbis-dev
 
Always download all the dependencies as well. Python should already be installed by Ubuntu at least, other distributions might require to install it separately.
 
If you get an error about the G++ compiler not being found, make sure you also install the <code>g++</code> package, and not just the <code>g++-4.1</code> package.
 
=== Ubuntu 7.10 ===
* g++
* scons 0.97
* libboost-dev
* libboost-regex-dev
* libgtk2.0-dev
* libglew1.4-dev
* libgtkglext1-dev
* libxml2-dev
* libboost-serialization-dev
* libboost-filesystem-dev
* libboost-date-time-dev
* libalut-dev
* libvorbis-dev
 
Always download all the dependencies as well.
 
For the D3Hook plugin, the boost/asio library is needed (version 0.3.7, newer versions don't work). This library is located in the plugins/dm.d3hook/boost/ folder and should be ready for compilation.
 
== Obtain the source ==
 
Install the subversion client. On Ubuntu this can be done via the Synaptic Manager or the command line:
sudo apt-get install subversion
 
Change to the directory where you want the source code to be in and then check the current version out of SVN with:
 
svn checkout https://darkradiant.svn.sourceforge.net/svnroot/darkradiant/trunk/darkradiant/ darkradiant
 
== Compile ==
 
Change to the source directory and use <code>scons</code> to create a release build:
 
cd darkradiant
scons BUILD="release"
 
The compilation can take quite a few minutes, depending on your system.
 
If you use <code>scons</code> without arguments, a debugging build will be created, which can take even longer.
 
Next time you want to compile DarkRadiant, you can just type '''scons''', the last build type is remembered by scons.
 
A fresh compile can be performed by clearing the compiled binaries first:
scons -c
scons BUILD="release"
 
If you want to update the source with the latest version from the SVN, just issue:
 
svn update
 
in the darkradiant source directory. <code>svn info</code> shows you what version you currently have.
 
= Note for users with Multiprocessor Systems =
Scons can run several jobs simultaneously, which can use your multicore system to its full capacity. By calling
 
scons JOBS="2"
 
the tool runs up to two compile tasks at the same time, which speeds up things a bit.
 
For a dual-core setup, a value of 2 jobs should be is sufficient, especially if you have only one Gbyte of memory, or less. If your machine has 2 or more Gbyte, you can also try higher values like:
 
scons JOBS="4"
 
= Installing Visual C++ 2005 Express Edition =
You can download Visual C++ 2005 Express Edition for free from Microsoft (the needed Platform SDK is also available for free):
* [http://msdn2.microsoft.com/de-de/express/aa718401(en-us).aspx MS VC++ 2005 Express Edition] (450 MB)
* [http://www.microsoft.com/downloads/details.aspx?FamilyId=D8EECD75-1FC4-49E5-BC66-9DA2B03D9B92&displaylang=en Platform SDK] (500 MB)
 
These are two hefty downloads, so watch your bandwidth. First, mount and install VC++ 2005 Express, this should be straight forward. This tutorial referring to the default installation paths from now on.
 
== Installing the Platform SDK ==
Mount the Platform SDK image and hit setup. You don't need to install everything from that package, so deselect everything except:
* Configuration Options (not sure about the child option Register Environment Variables, select that too)
* Microsoft Windows Core SDK
* Microsoft Data Access Services (MDAC) SDK
* Debugging Tools for Windows
 
Once you have the Platform SDK installed, you'll need to
* Open VC++ 2005
* Go to menu Tools > Options
* Go to Projects and Solutions > VC++ Directories
* Select "Show Directories for" Include files
* Add the folder C:\Program Files\Microsoft Platform SDK\Include
* Select "Show Directories for" Library files
* Add the folder C:\Program Files\Microsoft Platform SDK\Lib
* Then close VC++, go to the folder C:\Program Files\Microsoft Visual Studio 8\VC\VCProjectDefaults
* Open the file corewin_express.vsprops using a text editor and replace the XML key <Tool /> with this:
<Tool Name="VCLinkerTool" AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
  advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" />
 
Once that's done, restart VC++ and you should be ready to compile the DarkRadiant sources.
 
= How to compile the boost static libraries in Windows =
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:
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.regex
* boost.regex
Line 218: Line 51:
= See also =
= See also =
* [[DarkRadiant - Compilation Problems]]
* [[DarkRadiant - Compilation Problems]]
* [[DarkRadiant Linux Issues]]
* [http://msdn2.microsoft.com/de-de/express/aa718401(en-us).aspx MS VC++ 2005 Express Edition]
* [http://www.microsoft.com/downloads/details.aspx?FamilyId=D8EECD75-1FC4-49E5-BC66-9DA2B03D9B92&displaylang=en Platform SDK]


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

Revision as of 16:07, 4 April 2008

Obtain the Sources

The complete codebase plus all win32 dependencies are available at SourceForge. To check out the sources, open up Explorer and create the folder you want to store them.

First, download and install TortoiseSVN. Nothing special here, just install it into any folder of your preference. After installation it probably will ask to reboot your machine, as Tortoise integrates into the Explorer shell. (You can do that later, when all the other components have been installed).

Right-click somewhere in the white space and choose SVN Checkout. A new dialog appears asing you for the repository URL and the checkout folder. You can copy and paste the URL from here into the dialog window and click ok:

https://darkradiant.svn.sourceforge.net/svnroot/darkradiant/trunk/darkradiant/

Dr checkout.jpg

Check out the Dependencies (Win32)

For Windows builds, the dependencies must be checked out along with the sources. To keep the main source repository small, the dependencies are stored in a different folder next to the trunk:

https://darkradiant.svn.sourceforge.net/svnroot/darkradiant/trunk/w32deps/

To check them out in the correct folder, proceed like this: Go to the parent folder of the one you checked out the sources to. Given you checked them out in C:\DarkRadiant, go to the C:\ folder. Right-click somewhere in the white area of the explorer window and choose SVN > Checkout. (Note: it is necessary to right-click a folder which is not under version control, otherwise Tortoise won't provide the "Checkout" option). Make sure that the w32deps/ folder is created under the C:\DarkRadiant folder, like this:

Dr checkout dependencies.jpg

The resulting folder structure should look like this. The w32deps/ folder must be in the same folder as the radiant/ or include/ folder.

C:\
C:\DarkRadiant
C:\DarkRadiant\include\
C:\DarkRadiant\libs\
C:\DarkRadiant\plugins\
C:\DarkRadiant\radiant\
C:\DarkRadiant\w32deps\    <<----- w32deps/ is next to the radiant/ folder

Compiling

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

How to compile the boost static libraries in Windows

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.regex
  • boost.filesystem
  • boost.system

To build these static libraries, boost provides the jam tool (bjam.exe), which can be used to build the statics for you. Go get the boost sources from their website (http://www.boost.org) and extract them into a new folder. Then get bjam (can also be downloaded from their website, but you can also build it from scratch), open a console (Win-R ==> "cmd" => Enter) and head to:

cd <YOUR BOOST FOLDER HERE>
cd libs
cd filesystem
cd build
bjam --toolset=msvc link=static release stage
bjam --toolset=msvc link=static debug stage

After these commands, the libboost_filesystem_vc*.lib files (both debug and release variants) are in the stage/ directory below your boost folder. You'll need to repeat the above steps and replace filesystem with the names of the other libraries regex and system.

Now take the *.lib files and copy them into your w32deps/boost/lib folder in your darkradiant directory and the linking should succeed.

See also