Last modified 8 months ago Last modified on 10/02/11 00:41:58

Windows Compile Guide (MinGW)

Warning: These instructions don't work for master! Since the mingw build was not maintained, the respective makefiles have been removed.

The latest released version of the MinGW compiler for Windows is not compatible with the more recent versions of libraries which we use for trunk (though they're enough for 2.3) - see forums.wz2100.net/viewtopic.php?f=6&t=4991

Required software

First, we'll need to start by installing all of the required software. The first of these is the compiler, which in this case is GCC for Windows, also known as MinGW. You can download it and install it manually by collecting the right packages from the MinGW download page. It will probably be easier to use the automated installer though.

Then we'll need to install Bison and Flex. Just choose “Complete package, except sources” downloads for both of those, unless you have a particular reason to choose others.

Now that we've downloaded all of our packages, lets install them.

First start with the MinGW setup. Just select all the defaults until you encounter "Choose components". In that screen select at least (you can select more if you wish) "MinGW base tools", "g++ compiler" and "MinGW Make". Then continue and let the setup download all the required packages and install them.

Now we can install Flex and Bison, install both of them in a path which does not contain spaces. The default directories will do just fine, if they don't contain spaces.

Updating the %PATH%

In order for mingw32-make to work fine, you will need to add some directories %PATH% environment variable. In Windows 2000 and later you do this by right clicking "My Computer" then select "Properties" -> "Advanced" -> "Environment variables". Now in the subbox called "System variables" you should select "PATH" (or "Path"), click "Edit" (or "Modify" ?) and at the end of that line add ";C:\MinGW\bin;C:\Program Files\GnuWin32\bin" (assuming you installed MinGW into "C:\MinGW" and Flex as well as Bison in "C:\Program Files\GnuWin32"). The final path will then look like this (note the absence of the "double quotes"):

C:\WINDOWS\system32;C:\Windows;C:\MinGW\bin;C:\GnuWin32\bin

Getting the source code

You will now need to get the Warzone source code. For this install TortoiseSVN or the Subversion command line client (I'll explain TortoiseSVN here, using the command line client is explained here).

Now, after installing TortoiseSVN, create an empty directory where you want the source code to be downloaded into. Right click that directory and select "SVN Checkout...". In the window that appears enter this for "URL of repository": "https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk". Now click "OK" and the source code starts downloading, I suggest you grab a cup of coffee around now (as this might take about 5-10 minutes depending on the quality of your and gna.org's connection).

Note: Compiling the trunk generates an exe file that is not very useful for multi player games since it is very unlikely that there is someone online hosting a game with the latest revision of trunk. It is more probable that there are games for the latest release version of wz2100. If you want to join these games with your self compiled exe you need to checkout the 2.2 branch or one of the release tags instead of trunk.

Setting things up to get ready for compiling

Now download the developer's package, make sure to choose the most recent one that has "mingw32" and "2.2" in its name. If you want to build the translations (not required) you want the "extras" variant. Otherwise just take the smaller normal file.
You will need 7-Zip (a legally free archiving utility) to extract this file. We will assume you extracted the devpkg to "C:\devpkg" in the following.

In the directory where you extracted the Warzone 2100 sources to, copy makerules\config.mk.tmpl to makerules\config.mk and open the new file for editing (notepad will do just fine). Now uncomment this line:

 MODE=debug

(Removing the hash '#' sign will uncomment it).

Now set the DEVDIR line to the path where you extracted the developer's package (replace all backslashes by forward slashes, e.g. '\' should be '/'), and if you encounter any spaces in the path prefix those spaces with a backslash like this '\ '. So with the above path you'd have to use this line:

 DEVDIR=C:/devpkg

If you would have extracted the developer's package to "C:\Program Files\Warzone developer package" then your line would have to look like this instead:

 DEVDIR=C:/Program\ Files/Warzone\ developer\ package

Lets compile

Now open a command console ("Start" -> "Run" -> "cmd.exe" -> "OK"). Go to the directory where you downloaded the source code

 cd /d "X:\directory\where\the warzone source\is found"

In that directory type the following to start compiling:

 mingw32-make -f makefile.win32

When this command finishes without error you should have a warzone2100.exe in the "src" directory which you can execute.

Updating to the latest version

You could now try to update to the latest version of warzone by right clicking on the warzone source directory and selecting "SVN Update". When that's finished you can recompile warzone according to the above section.

Sometimes you need to execute this command to make sure that the source tree is cleaned up properly before rebuilding/recompiling:

 mingw32-make -f makefile.win32 clean