Compiling Zandronum with Visual Studio: Difference between revisions

From Zandronum Wiki
(Rename thg section to just Mercurial; point to mercurial-scm.org as it tends to be more up to date than the thg site)
Tag: Source edit
 
(31 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Prerequisites =
= Prerequisites =
== Visual Studio ==
Zandronum requires the Visual Studio 2015 toolchain to be built. Microsoft no longer offers 2015 for (easy) download, but forunately, modern versions of Visual Studio can use older toolchains.
<ol>
<li>Download [https://visualstudio.microsoft.com/downloads/ Visual Studio 2022 Community].</li>
<li>In the installer, select the '''Desktop development with C++''' workload.
[[File:Vs2022 cppdevel.png|none]]</li>
<li>On the '''Individual components''' tab, scroll down to the '''Compilers, build tools, and runtimes''' section, and select the '''MSVC v140 - VS 2015 C++ build tools (v14.00)''' and '''C++ Windows XP Support for VS 2017 (v141) tools''' components.</li>
<li>Proceed with the installation.</li>
</ol>
== CMake ==
Download the latest version of CMake from [http://cmake.org cmake.org]. We will use this to generate the projects.
== NASM ==
== NASM ==
http://www.nasm.us/
http://www.nasm.us/


For VC++ 2015, the latest nasm version is required. Currently, this is [http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/nasm-2.11.08.zip Version 2.11.08].
For Visual Studio 2015 or newer, the latest nasm version is required. Currently, this is [http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/nasm-2.11.08.zip Version 2.11.08].
 
For VC++ 2005, [http://www.nasm.us/pub/nasm/releasebuilds/2.00/nasm-2.00-win32.zip Version 2.00] (no older nor newer) is required.


== FMOD Ex ==
== FMOD Ex ==
http://www.fmod.org/browse-fmod-ex-api/
The old FMOD Ex links were removed from the FMOD website, so ZDoom has archived them at https://zdoom.org/files/fmod/.


:Version 4.24.x is required, version 4.24.16 recommended
For Zandronum 3.1, version 4.44.64 is recommended (the final release of FMOD Ex.)
:Used for multimedia
:Quick Windows link: https://zdoom.org/files/fmod/fmodapi44464win-installer.exe
:Quick Windows link: http://www.fmod.org/download/fmodex/api/Win/fmodapi42416win32-installer.exe
<!-- IGNORE THIS FOR NOW :x64 platforms use this: http://www.fmod.org/download/fmodex/api/Win/fmodapi42416win64-installer.exe -->


== TortoiseHg ==
For Zandronum 3.0, version 4.24.x is required, version 4.24.16 recommended
http://tortoisehg.bitbucket.org/download/index.html
:Quick Windows link: https://zdoom.org/files/fmod/fmodapi42416win32-installer.exe
<!-- IGNORE THIS FOR NOW :x64 platforms use this: https://zdoom.org/files/fmod/fmodapi42416win64-installer.exe -->


Used for downloading the soruce and fetching the Mercurial revision ID when compiling the build.
== Mercurial ==
Download the latest version of TortoiseHg for Windows from [https://www.mercurial-scm.org/ the Mercurial website]. This bundle includes Mercurial itself and the TortoiseHg graphical user interface.


== Windows Platform SDK ==
Used for downloading the source code and fetching the Mercurial revision ID when compiling the build.
<!-- Because I had this problem when trying to install the package and received nothing but issues including signature errors and whatnot, really - use what is recommended! Thanks for the help Torr! -Tiger -->
http://www.microsoft.com/en-us/download/details.aspx?id=18950


Version 7.0 or older is required.
If you wish to build a specific topic, you must enable the <tt>topic</tt> and <tt>evolve</tt> Mercurial extensions. To do so, either:
'''IMPORTANT''': If you are on x64, get the GRMSDKX version, the ones without the X will not work.
* Open TortoiseHg Workbench, go to the File menu -> Settings, open the global settings tab, open the Extensions section, and select the <tt>topic</tt> and <tt>evolve</tt> extensions, then completely exit TortoiseHg Workbench.
* or, manually add the following to <tt>mercurial.ini</tt> in your user directory:
  <syntaxhighlight lang="ini">
[extensions]
topic =
evolve =
</syntaxhighlight>


== DirectX SDK ==
== DirectX SDK ==
http://www.microsoft.com/en-us/download/details.aspx?id=10084
https://wiki.zandronum.com/files/DXSDK_Feb10.exe


Version 9.28.1886
Zandronum depends on DirectDraw for software rendering on Windows, so the February 2010 SDK release is required.
Used for compiling the DirectX code within ZDoom.


== OpenGL Header Files ==
== OpenGL Header Files ==


*OpenGL 1.2 and above compatibility profile and extension interfaces: [http://www.opengl.org/registry/api/glext.h glext.h]
*OpenGL 1.2 and above compatibility profile and extension interfaces: [https://www.khronos.org/registry/OpenGL/api/GL/glext.h glext.h]
*WGL Extension interfaces: [http://www.opengl.org/registry/api/wglext.h wglext.h]
*WGL Extension interfaces: [https://www.khronos.org/registry/OpenGL/api/GL/wglext.h wglext.h]


Note that you may need to put the glext.h and wglext.h into your <tt>C:\Program Files\Microsoft SDKs\Windows\v6.1\includes\gl</tt> folder.
Note that you may need to put the glext.h and wglext.h into your <tt>C:\Program Files\Microsoft SDKs\Windows\v6.1\includes\gl</tt> folder (create it if it doesn't exist).
To resolve compiling issues under 'gl_clock.cpp' with _interlockedbittestandset and _interlockedbittestandreset, refer [http://forum.drdteam.org/viewtopic.php?p=43104& here]
To resolve compiling issues under 'gl_clock.cpp' with _interlockedbittestandset and _interlockedbittestandreset, refer [http://forum.drdteam.org/viewtopic.php?p=43104& here]


== OpenSSL ==
== OpenSSL ==


Precompiled versions of OpenSSL for Windows are available from [https://slproweb.com/products/Win32OpenSSL.html Shining Light Productions].  You will want the latest non-light edition of OpenSSL 1.0.2 - the description of the correct package mentions "software developers".  You should have a choice between 32-bit and 64-bit versions - you will most likely need the 32-bit version unless you are using CMake and select the 64-bit compiler when generating your build files.
OpenSSL is necessary in order for Zandronum to communicate securely with the account authentication server.
 
=== Wait, why do we need this huge library? ===


The authentication protocol needs OpenSSL for "Big Integer" math, a cryptographically secure random number generator, and the SHA256 hash function.
Precompiled binaries for Windows are available from [https://slproweb.com/products/Win32OpenSSL.html Shining Light Productions].  You will want the latest '''non-light''' edition of OpenSSL (both 3.x.x and 1.x.x are known to work) - the description of the correct package mentions "software developers".  You should have a choice between 32-bit and 64-bit versions - you will most likely need the 32-bit version unless you are using CMake and select the 64-bit compiler when generating your build files.


=== Building OpenSSL ===
=== Building OpenSSL ===


If the above packages don't work for you for some weird reason, you can try compiling OpenSSL yourself. This is going to be a huge pain in the neck, so be '''sure''' that the Shining Light distributions of OpenSSL definitely don't work before you try this.
If the above packages do not work, you can compile OpenSSL yourself. This is a lengthy and complicated process, so be sure that the existing binaries of OpenSSL definitely don't work before you try this.


Perl is necessary to build OpenSSL. If you don't have Perl installed already, install [http://www.activestate.com/activeperl ActiveState Perl].
* Perl is necessary to build OpenSSL. If you don't have Perl installed already, install [http://www.activestate.com/activeperl ActiveState Perl].


* NASM executable directory <I>must</I> be in the host system's Environment Variables.  Meaning, that NASM must be in the system's $PATH (or %PATH%).
* NASM executable directory must be in the host system's <code>PATH</code> environment variable.


* Download and decompress the latest source of [https://www.openssl.org/source/ OpenSSL]. In the openssl source directory call
* Download and decompress the latest source of [https://www.openssl.org/source/ OpenSSL]. In the source directory call


  perl Configure VC-WIN32 --prefix=c:\Tools\Util\openssl
  perl Configure VC-WIN32 --prefix=c:\Tools\Util\openssl
  ms\do_nasm
  ms\do_nasm


* Replace "c:\Tools\Util\openssl" with the path where you want OpenSSL to be installed. Then, in the same directory, but within a [http://msdn.microsoft.com/en-us/library/ms229859%28v=vs.110%29.aspx VC++ command prompt], call
* Replace <code>c:\Tools\Util\openssl</code> with the path where you want OpenSSL to be installed. Then, in the same directory, but within a [http://msdn.microsoft.com/en-us/library/ms229859%28v=vs.110%29.aspx VC++ command prompt], call


  nmake -f ms\nt.mak
  nmake -f ms\nt.mak
Line 68: Line 84:
  nmake -f ms\nt.mak install
  nmake -f ms\nt.mak install


NOTE: If an error message 'WinSock32.h does not exist!' is displayed (or the like), you'll need to add these two lines to your console's temporary environment:<br>
* If an error message 'WinSock32.h does not exist!' is displayed (or the like), you'll need to add these two lines to your console's temporary environment:
  <code>SET INCLUDE=%INCLUDE%;c:\Program Files\Microsoft SDKs\Windows\v7.0\Include\</code><br>
 
  <code>SET LIB=%LIB%;c:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\</code>
  SET INCLUDE=%INCLUDE%;c:\Program Files\Microsoft SDKs\Windows\v7.0\Include\
  SET LIB=%LIB%;c:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\


== Python ==
== Python ==
Line 76: Line 93:


Version 3.5 or newer is required.
Version 3.5 or newer is required.
== Opus ==
The Opus audio codec is required for voice chat support.
Download the latest libopus archive from [https://opus-codec.org/downloads/ the Opus website]. Extract the archive, then open the <tt>win32\VS2015\opus.sln</tt> solution (allow Visual Studio to upgrade the projects if necessary). Build the <tt>Release</tt> configuration for the same platform you will build Zandronum for (Win32 or x64).
After building, you will have a static library built under your libopus directory at <tt>win32\VS2015\Win32\Release\opus.lib</tt> or <tt>win32\VS2015\x64\Release\opus.lib</tt>. Pass the full path to the relevant library as the <tt>OPUS_LIBRARIES</tt> variable when it comes time to run CMake. Additionally, pass the libopus <tt>include</tt> folder as <tt>OPUS_INCLUDE_DIR</tt>.


== Zandronum Source Code ==  
== Zandronum Source Code ==  
Line 82: Line 107:


In the directory where you want to download the source, right-click on empty space, and go to <code>TortoiseHg &rarr; Clone</code>.
In the directory where you want to download the source, right-click on empty space, and go to <code>TortoiseHg &rarr; Clone</code>.
Enter <code>https://bitbucket.org/Torr_Samaho/zandronum</code> as the source.
Enter <code>https://foss.heptapod.net/zandronum/zandronum-stable</code> as the source.


If you want to clone a specific revision, expand ''Options'', check ''Clone to revision'', and enter the revision you want to clone.
If you want to clone a specific revision, expand ''Options'', check ''Clone to revision'', and enter the revision you want to clone.


For example, if you wanted to download Zandronum 2.1.2's source, you'd enter <code>ZA_2.1.2</code>.
For example, if you wanted to download [[Version history/{{LatestVersion}}|Zandronum {{LatestVersion}}]]'s source, you'd enter <code>ZA_{{LatestVersion}}</code>.


== Optional prerequisites ==
== Optional prerequisites ==
Line 92: Line 117:
Only available with the keyboard drivers from [http://www.logitech.com/ Logitech] hardware.
Only available with the keyboard drivers from [http://www.logitech.com/ Logitech] hardware.


= Using Visual Studio 2005 - 2015 =
= Build using Visual Studio =
== Prerequisites ==
== Generate Projects ==
=== Visual Studio ===
[[File:Vs2022 cmake.PNG|thumb|right]]
You will require Visual Studio to compile Zandronum.
In this guide, Visual Studio 2013 will be used, however it is recommended Visual Studio 2015 is used instead (the instructions are the same).


=== CMake ===
Open CMake (<code>cmake-gui</code>) and set the ''Where is the source code'' textbox to where you downloaded the Zandronum source code. Set ''Where to build the binaries'' to wherever you want the project files to be generated.
Download the latest version of CMake from [http://cmake.org cmake.org]. We will use this to generate the projects.
Click ''Configure'' and a dialog will pop up.


== Generate Projects ==
* Set the generator to '''Visual Studio 17 2022'''.
Open CMake (<code>cmake-gui</code>) and set the ''Where is the source code'' textbox to where you downloaded the Zandronum source code. Set ''Where to build the binaries'' to wherever you want the project files to be generated.
* Set the platform to '''Win32''' for a 32-bit build or '''x64''' for a 64-bit build.
Click ''Configure'' and select what you want to generate projects for.
* Set the toolset to '''v140_xp'''.


If it says there was an error, ignore it as we will solve it now.
If it says there was an error, ignore it as we will solve it now.
Make sure you set up all prerequisites correctly, and point CMake to the location of any missing paths.
Make sure you set up all prerequisites correctly, and point CMake to the location of any missing paths. Select the '''Advanced''' and '''Grouped''' checkboxes to reveal and group all options.


Then click ''Configure'' again, and point CMake to missing paths.
Then click ''Configure'' again, and point CMake to missing paths.
Line 112: Line 135:
YASM is unneeded as we already have NASM.
YASM is unneeded as we already have NASM.


[[Image:PSVSGuide_CMake_Complete.png|thumb|left|Your CMake should look like this]]
[[File:PSVSGuide CMake Complete.png|none|thumb|300x300px|Your CMake should look like this]]
 
Click ''Configure'' again and your CMake should look like the image on the left.
Click ''Configure'' again and your CMake should look like the image on the left.
Now click ''Generate''. This will generate the project files.
Now click ''Generate''. This will generate the project files.


== Build Zandronum ==
== Build Zandronum ==
[[Image:PSVSGuide_Open_Zansln.png|thumb|right]]
Now go to where you generated the project files and open <code>Zandronum.sln</code>.
Now go to where you generated the project files and open <code>Zandronum.sln</code>.


Line 130: Line 153:
Once successfully compiled, <code>zandronum.exe</code> will be in the <code>Debug</code> folder in the project directory.
Once successfully compiled, <code>zandronum.exe</code> will be in the <code>Debug</code> folder in the project directory.
<code>zandronum.pk3</code> will be in the project directory.
<code>zandronum.pk3</code> will be in the project directory.
= Using Visual Studio 2005 =
[[Image:VisualStudio2005.png|thumb|right|Zandronum's Source Code in Microsoft Visual Studio C++ 2005]]
== Prerequisites ==
=== Microsoft Visual Studio C++ 2005 Express Edition ===
Download: http://go.microsoft.com/fwlink/?linkid=57034
Version 2005 is recommended, including the necessary [http://msdn.microsoft.com/en-us/vstudio/aa948853.aspx updates]. The easiest way to install is to extract the <tt>VC.iso</tt> file using 7-zip to a directory and run <tt>setup.exe</tt>.
On Windows Vista and older:
*[http://www.microsoft.com/en-us/download/details.aspx?id=804 VS C++ 2005 (Express Editions) - Service Pack 1]
*[http://www.microsoft.com/en-us/download/details.aspx?id=7524 VS 2005 Service Pack 1 Update for Windows 6 Foundation(Vista/Windows7/etc.)]
It is possible to compile the project using more recent versions of Visual Studio, but these binaries may not be compatible with older Windows systems.
=== SQLite ===
Download the ZIP archive containing the amalgamation of SQLite version 3.8.10.1 [https://www.sqlite.org/2015/sqlite-amalgamation-3081001.zip here], extract the files <code>sqlite3.c</code>, <code>sqlite3.h</code> and <code>sqlite3ext.h</code> from the archive and put them into the sqlite directory of the Zandronum source.
== Configuring Visual Studio ==
[[Image:VisualStudio2005DirSetup.png|thumb|right|Directory Setup in Microsoft Visual Studio C++ 2005]]
In order to compile the Zandronum project, we must first include several items of dependencies.  Go to <u title="Tools - Options - Projects and Solutions - VC++ Directories">VC++ Directories</u> settings, and do the following:
=== Executable Files ===
Add the following executables:
==== NASM ====
:Typically the same location that the archive file was extracted from.  For example: <tt>C:\NASM\</tt>
=== Includes ===
[[Image:VisualStudio2005DirSetup_Includes.png|thumb|right|Directory Setup in Microsoft Visual Studio C++ 2005]]
Add the following to the Includes:
==== <code>$(DXSDK_DIR)Include</code> ====
:This is the DirectX SDK.  The code above translates to an Environment Variable.
==== FMOD Ex ====
:FMOD Ex can typically be located at: <code>C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api\inc\</code>
==== OpenGL Header files ====
:This can be located at any directory placed.
==== OpenSSL ====
:Within the OpenSSL directory (where the contents were extracted and [[Compiling_Zandronum_on_Visual_Studio#OpenSSL | installed]]), the 'include' directory will be needed.
::Example: <code>C:\OpenSSL\Include</code>
=== Library Files ===
[[Image:VisualStudio2005DirSetup_Library.png|thumb|right|Directory Setup in Microsoft Visual Studio C++ 2005]]
Add the following to the 'Library' list:
==== <code>$(DXSDK_DIR)Lib\x86</code> ====
:This, again, is the DirectX SDK environment variable with a location directory included.
==== FMOD Ex Library ====
:This is typically located at: <code>C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api\lib</code>
==== Logitech LCD SDK ====
:This is typically located in archive file (if G15 drivers installed): <code>C:\Program Files\Logitech Gaming Software\LCDSDK\LCDSDK_(VERSION).zip</code>
:If installed without the drivers, place the correct path to 'lglcd.lib' in the path.
==== OpenSSL ====
:Within the OpenSSL directory (where the contents were extracted and [[Compiling_Zandronum_on_Visual_Studio#OpenSSL | installed]]), the 'lib' directory will be needed.
::Example: <code>C:\OpenSSL\lib</code>
== Compiling the Project ==
Before you compile the project make sure you do not have <tt>Debug DLL</tt> selected near the top middle of the main screen of Visual C++ 2005. It should be set to <tt>Release</tt>. This is in a dropdown menu most likely beneath the 'Community' and 'Windows' tab at the top.
To compile the project, go to: '''Build''' and then '''Build Solution'''


= Troubleshooting =
= Troubleshooting =
== Cannot find Windows.h or WinSock2.h (and probably many more errors) ==
Sometimes upon installation of the SDK, it will not properly update the path that VC 2005+ automatically comes with. Therefore you have to manually add the fix in your <u title="Tools - Options - Projects and Solutions - VC++ Directories">VC++ Directories</u> under "Includes" by manually adding the path to the Windows include folder.
This is an example of what you may have to add to fix the problem:
<code>C:\Program Files\Microsoft SDKs\Windows\v7.0\Include</code>
== Cannot find gdi32.lib (or [name].lib) ==
Like the above, sometimes upon installation of the SDK... it will not properly update the path that VC 2005+ automatically comes with. Therefore you have to manually add the fix in your <u title="Tools - Options - Projects and Solutions - VC++ Directories">VC++ Directories</u> under "Libraries" by manually adding the path to the Windows library folder.
This is an example of what you may have to add to fix the problem:
<code>C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib</code>
== OpenGL (_interlockedbittestandset) Issue ==
You will want to comment out the lines at intrin.h, it's location can be found most likely at this location:
<code>C:\Program Files\Microsoft Visual Studio 8\VC\include</code>
The code would look as follows (add the slashes before to fix the problem):
  ...
  //__MACHINEI(unsigned char _interlockedbittestandset(long *a, long b))
  //__MACHINEI(unsigned char _interlockedbittestandreset(long *a, long b))
  ...
== Cannot find GL/glext.h ==
That means you have to place your GL files in your SDK directory like so:
<code>C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\gl</code>
== 'Cr0NpxState' : is not a member of _FLOATING_SAVE_AREA ==
== 'Cr0NpxState' : is not a member of _FLOATING_SAVE_AREA ==


Line 238: Line 160:


== error LNK1281: Unable to generate SAFESEH image ==
== error LNK1281: Unable to generate SAFESEH image ==
When using VC++ 2015, update to the latest nasm version.
When using Visual Studio 2015 or newer, update to the latest nasm version.


[[Image:PSVSBuild_Safesehno.png|thumb|right]]
[[Image:PSVSBuild_Safesehno.png|thumb|right]]

Latest revision as of 20:02, 25 March 2024

Prerequisites

Visual Studio

Zandronum requires the Visual Studio 2015 toolchain to be built. Microsoft no longer offers 2015 for (easy) download, but forunately, modern versions of Visual Studio can use older toolchains.

  1. Download Visual Studio 2022 Community.
  2. In the installer, select the Desktop development with C++ workload.
  3. On the Individual components tab, scroll down to the Compilers, build tools, and runtimes section, and select the MSVC v140 - VS 2015 C++ build tools (v14.00) and C++ Windows XP Support for VS 2017 (v141) tools components.
  4. Proceed with the installation.

CMake

Download the latest version of CMake from cmake.org. We will use this to generate the projects.

NASM

http://www.nasm.us/

For Visual Studio 2015 or newer, the latest nasm version is required. Currently, this is Version 2.11.08.

FMOD Ex

The old FMOD Ex links were removed from the FMOD website, so ZDoom has archived them at https://zdoom.org/files/fmod/.

For Zandronum 3.1, version 4.44.64 is recommended (the final release of FMOD Ex.)

Quick Windows link: https://zdoom.org/files/fmod/fmodapi44464win-installer.exe

For Zandronum 3.0, version 4.24.x is required, version 4.24.16 recommended

Quick Windows link: https://zdoom.org/files/fmod/fmodapi42416win32-installer.exe

Mercurial

Download the latest version of TortoiseHg for Windows from the Mercurial website. This bundle includes Mercurial itself and the TortoiseHg graphical user interface.

Used for downloading the source code and fetching the Mercurial revision ID when compiling the build.

If you wish to build a specific topic, you must enable the topic and evolve Mercurial extensions. To do so, either:

  • Open TortoiseHg Workbench, go to the File menu -> Settings, open the global settings tab, open the Extensions section, and select the topic and evolve extensions, then completely exit TortoiseHg Workbench.
  • or, manually add the following to mercurial.ini in your user directory:
[extensions]
topic = 
evolve =

DirectX SDK

https://wiki.zandronum.com/files/DXSDK_Feb10.exe

Zandronum depends on DirectDraw for software rendering on Windows, so the February 2010 SDK release is required.

OpenGL Header Files

  • OpenGL 1.2 and above compatibility profile and extension interfaces: glext.h
  • WGL Extension interfaces: wglext.h

Note that you may need to put the glext.h and wglext.h into your C:\Program Files\Microsoft SDKs\Windows\v6.1\includes\gl folder (create it if it doesn't exist). To resolve compiling issues under 'gl_clock.cpp' with _interlockedbittestandset and _interlockedbittestandreset, refer here

OpenSSL

OpenSSL is necessary in order for Zandronum to communicate securely with the account authentication server.

Precompiled binaries for Windows are available from Shining Light Productions. You will want the latest non-light edition of OpenSSL (both 3.x.x and 1.x.x are known to work) - the description of the correct package mentions "software developers". You should have a choice between 32-bit and 64-bit versions - you will most likely need the 32-bit version unless you are using CMake and select the 64-bit compiler when generating your build files.

Building OpenSSL

If the above packages do not work, you can compile OpenSSL yourself. This is a lengthy and complicated process, so be sure that the existing binaries of OpenSSL definitely don't work before you try this.

  • Perl is necessary to build OpenSSL. If you don't have Perl installed already, install ActiveState Perl.
  • NASM executable directory must be in the host system's PATH environment variable.
  • Download and decompress the latest source of OpenSSL. In the source directory call
perl Configure VC-WIN32 --prefix=c:\Tools\Util\openssl
ms\do_nasm
  • Replace c:\Tools\Util\openssl with the path where you want OpenSSL to be installed. Then, in the same directory, but within a VC++ command prompt, call
nmake -f ms\nt.mak
nmake -f ms\nt.mak test
nmake -f ms\nt.mak install
  • If an error message 'WinSock32.h does not exist!' is displayed (or the like), you'll need to add these two lines to your console's temporary environment:
SET INCLUDE=%INCLUDE%;c:\Program Files\Microsoft SDKs\Windows\v7.0\Include\
SET LIB=%LIB%;c:\Program Files\Microsoft SDKs\Windows\v7.0\Lib\

Python

https://www.python.org/downloads/

Version 3.5 or newer is required.

Opus

The Opus audio codec is required for voice chat support.

Download the latest libopus archive from the Opus website. Extract the archive, then open the win32\VS2015\opus.sln solution (allow Visual Studio to upgrade the projects if necessary). Build the Release configuration for the same platform you will build Zandronum for (Win32 or x64).

After building, you will have a static library built under your libopus directory at win32\VS2015\Win32\Release\opus.lib or win32\VS2015\x64\Release\opus.lib. Pass the full path to the relevant library as the OPUS_LIBRARIES variable when it comes time to run CMake. Additionally, pass the libopus include folder as OPUS_INCLUDE_DIR.

Zandronum Source Code

And of course, you will require the Zandronum source code to build Zandronum! You must clone the source with Mercurial to create a build that is compatible with servers.

In the directory where you want to download the source, right-click on empty space, and go to TortoiseHg → Clone. Enter https://foss.heptapod.net/zandronum/zandronum-stable as the source.

If you want to clone a specific revision, expand Options, check Clone to revision, and enter the revision you want to clone.

For example, if you wanted to download Zandronum 3.1's source, you'd enter ZA_3.1.

Optional prerequisites

Logitech G-Series LCD SDK

Only available with the keyboard drivers from Logitech hardware.

Build using Visual Studio

Generate Projects

Open CMake (cmake-gui) and set the Where is the source code textbox to where you downloaded the Zandronum source code. Set Where to build the binaries to wherever you want the project files to be generated. Click Configure and a dialog will pop up.

  • Set the generator to Visual Studio 17 2022.
  • Set the platform to Win32 for a 32-bit build or x64 for a 64-bit build.
  • Set the toolset to v140_xp.

If it says there was an error, ignore it as we will solve it now. Make sure you set up all prerequisites correctly, and point CMake to the location of any missing paths. Select the Advanced and Grouped checkboxes to reveal and group all options.

Then click Configure again, and point CMake to missing paths. LIB_EAY and SSL_EAY are OpenSSL libraries. YASM is unneeded as we already have NASM.

Your CMake should look like this

Click Configure again and your CMake should look like the image on the left. Now click Generate. This will generate the project files.

Build Zandronum

Now go to where you generated the project files and open Zandronum.sln.

At the top, there will be a Build menu. Click it and click Build Solution.

Now wait for Zandronum to build. It is a large project and will take time to build.

If you encounter an error, see Troubleshooting below.

Once successfully compiled, zandronum.exe will be in the Debug folder in the project directory. zandronum.pk3 will be in the project directory.

Troubleshooting

'Cr0NpxState' : is not a member of _FLOATING_SAVE_AREA

Just comment out the line that calls this, according to zdoom devs, it is only there to give info and doesn't actually affect the project.

error LNK1281: Unable to generate SAFESEH image

When using Visual Studio 2015 or newer, update to the latest nasm version.

Set `/SAFESEH:NO` by going into the properties of the `zdoom` project and navigating to Configuration Properties → Linker → Advanced and changing Image Has Safe Exception Handlers to No (/SAFESEH:NO).

Related Articles