Building Zandronum from source on Windows XP/Vista/Seven

Many may find this interesting, because currently there are no daily build hosts. Remember that when you’re running 32-bit program in 64-bit OS it takes almost twice more memory. In this mini “how to” I'll try to tell how to build Zandronum from scratch for both Windows x86 and x64. For this article I’ve used my home machine with Windows 7 x64 and built the latest Zandronum revision. Note that your Windows user (and profile C:\Users\user) must NOT contain internationalized characters!

Let's split the process by 6 stages:
1) Downloading development environments and libraries
2) Installing and configuring the environment
3) Getting the sources
4) Creating x64 configuration in project
5) Fixing the code for x64 compatibility
6) Compiling and harvesting obtained binaries

If you do this not for the first time – you may proceed directly to step 3.

1. Downloads
1.1. Required downloads

1. Microsoft Visual Studio 2005 Professional - you can get it anywhere you want. Express edition is free but it doesn't have 64-bit compiler.
2. Microsoft Platform SDK 2008 - mount the image or extract using an archive program (like WinRAR).
3. Visual Studio Libraries for Doom Ports - Includes DirectX SDK (Feb 2010), Logitech LCD SDK, SDL libraries
4. FMOD API Collection for Doom Ports - Includes various FMOD versions for all ZDoom based ports
5. NASM 2.08.02 - 32-bit assembler.
6. YASM 1.2.0 x64 - 64-bit assembler.
7. glext.h and wglext.h - OpenGL headers


1.2. Optional downloads

1. Mercurial 2.4 - program for grabbing the sources.
2. CMake 2.8.10.1 - universal C++ project generator (will be used to automatically create x64 configuration).
3. diff + deps + patch - programs to patch text files.


2. Installing programs
1. Install VS2005 in "Full" variant to support 64-bit compilers. Upon the first launch select "Visual C++ Development Layout" in popup window.
2. Close VS and open file "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\1033\AppSettings.htm". Comment out lines 357-359 like this:
// WIN_APP.disabled = true;
// DLL_APP.disabled = true;
// LIB_APP.disabled = true;
3. Comment out lines 912,913,918,919 in file "C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h". First should be
"__MACHINEI(unsigned char _interlockedbittestandset(long *a, long b))"
4. Comment out lines 944,945 in file "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\intrin.h". First should be
"__MACHINEI(unsigned char _interlockedbittestandset(long *a, long b))"
5. Install Platform SDK into default directory selecting variants shown in this screenshot.
6. Extract Doom libraries to C:\ (will be C:\libs), extract FMOD collection to C:\libs.
7. Rename downloaded YASM to yasm.exe and place it into "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\x86_amd64".
8. Extract NASM archive into "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\Bin" and copy nasm.exe to nasmw.exe.
9. Place OpenGL headers to "C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\gl".
10. Install Mercurial into default directory. Don't uncheck "Add the installation path to the search path" in last step of wizard!
11. Install CMake into default directory. Select "Add CMake to the system PATH for current user" when asked.
12. Open Visual Studio and select in menu Tools - Options. Go to Projects and Solutions - VC++ Directories.
13. In "Platform" dropdown select Win32, then Show directories for - Include files. Add paths:
C:\libs\include - should be on top of the list
C:\Program Files\Microsoft SDKs\Windows\v6.1\Include
C:\libs\fmod424\api\inc
Delete path:
$(VCInstallDir)PlatformSDK\include
14. In "Show directories for" dropdown select "Library files". Add paths:
C:\libs\lib\x86 - should be on top of the list
C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib
C:\libs\fmod424\api\lib
Delete path:
$(VCInstallDir)PlatformSDK\lib
15. In "Platform" dropdown select x64, then "Show directories for" - Include files. Add paths:
C:\libs\include - should be on top of the list
C:\Program Files\Microsoft Visual Studio 8\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include
C:\Program Files\Microsoft SDKs\Windows\v6.1\Include
C:\libs\fmod424_x64\api\inc
Delete paths:
$(VCInstallDir)include
$(VCInstallDir)PlatformSDK\include
16. In "Show directories for" dropdown select "Library files". Add paths:
C:\libs\lib\x64 - should be on top of the list
C:\Program Files\Microsoft Visual Studio 8\VC\lib\amd64
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\lib\amd64
C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib\x64
C:\libs\fmod424_x64\api\lib
Delete paths:
$(VCInstallDir)lib\amd64
$(VCInstallDir)PlatformSDK\lib\amd64
17. Done configuring the environment.

3. Obtaining source code
1) Let's download the latest sources. Open a console (cmd.exe) and go to folder you need. Execute a command:
hg clone https://bitbucket.org/Torr_Samaho/zandronum
Sources will be downloaded to zandronum subfolder. If you see corrupted fonts of hg program, delete the folder "C:\Program Files\Mercurial\locale".
2) If you want you may download a stable version. Go to "Tags" tab, find the version you want, and download is as zip. Extract the downloaded archive to a folder you need.
3) To update the existing source code, execute that command again:
hg clone https://bitbucket.org/Torr_Samaho/zandronum

4. Creating 64-bit configuration. - Skip this if you want just 32-bit version.
4.1. Manual creation
1) Load the solution "zandronum.sln" in Visual Studio.
2) In first dropdown on toolbar (Solution Configurations) select "Release", but in second (Solution Platforms) select "Configuration Manager..."
3) In the "Active solution platform" select "<Edit>" and delete x64.
4) Return to Configuration Manager and in field "Active solution platform" select "<New>".
5) In the popped up window put x64 into first field and press OK.
6) Opposite to "lemon" and "re2c" projects select "Win32" in "Platform" field. Close Configuration Manager and save the solution.
7) In Solution Explorer go to properties of "zandronum" project:
Configuration Properties - C++ - General - Additional Include Directories
add the following lines:
jpeg-6b, snes_spc\snes_spc, gdtoa, bzip2, lzma\C, src\OpenGL, src\win32\g15\include
then in
Linker - General - Output File
put
"../zandronum64.exe"
next go to
Linker - Input - Additional Dependencies
replace fmodvc.lib with fmodex64_vc.lib then add opengl32.lib and glu32.lib. Then go to
Linker - Command Line - Additional Options
and clear the contents.
8) Press OK and save the solution (Ctrl+Shift+S).
9) This should be enough to build Zandronum. For next time you may use the ready zandronum.sln and zdoom.vcproj files. I recommend to create a patch with diff program and apply it to projects files in case they will change.

4.2. Automatic creation using CMake
1) Create a folder named "zabuild" next to "zandronum", open a console and cd to it
2) Execute a command:
cmake -G "Visual Studio 8 2005 Win64" ../zandronum
3) Done. Use Project.sln instead of zandronum.sln in next steps.

5. Fixing the source for x64 workaround. - Skip this if you want just 32-bit version.
Unlike (G)ZDoom, Zandronum has several problems in source code that prevent it to compile for win64 platform. Thus we will disable some features to make it work. They include server GUI, HQNX scaling and some Raven games functions. You can use Visual Studio to edit C++ files.

6. Compiling the source
1) Open Visual Studio and load file zandronum.sln.
2) In first dropdown on toolbar (Solution Configurations) select "Release", but in second (Solution Platforms) select your platform.
3) Launch compilation process by selecting Menu Build - Build Solution (don't pay attention to "Updating IntelliSense" in status bar).
4) If some projects fail to compile try to launch the Build once again, you will see which errors exactly happened.
5) After compilation is done in parent folder relatively to "zandronum" several files should appear: zandronum.exe or zandronum64.exe.
6) For Zandronum to work properly following files are required:
1. zandronum.exe and zandronum.pk3 from the folder where it was compiled.
2. fmodex.dll from C:\libs\fmod424\api OR fmodex64.dll from C:\libs\fmod424_x64\api
3. skulltag_actors.pk3 (optional) contains latest DECORATE definitions for Skulltag stuff

zandronum.exe is native for Windows XP. It can be run in Windows 98 or higher.


You will see version number in window title, in console or by "gameversion" command. If your windows is installed not in C:, use your letter everywhere in this "how to".