Compiling UnrealIRCd on Windows

''NOTE: This article is for experienced developers only. Everyone else should follow Installing (Windows) instead.''

Should I compile myself?
The UnrealIRCd project provides precompiled binaries and an installer. If you're after something simple then see Installing (Windows).

If, however, you are a developer and want to compile UnrealIRCd yourself, then follow this article. Possible reasons for doing so:
 * 1) You want to compile a 3rd party module on Windows
 * 2) You want to tweak a compile-time setting (such as in include\config.h or include\struct.h)
 * 3) You want to make source code changes

Which compilers are supported
The official UnrealIRCd releases are compiled with Visual Studio 2019 (also called Visual Studio 16.x). We suggest you use this version too. Visual Studio Community edition can be downloaded free of charge for personal use (and for open source projects) via https://visualstudio.microsoft.com/

Other compilers such as Cygwin or MinGW will not work and are not supported.

External libraries
UnrealIRCd uses a number of libraries. We already built them on Windows for you, so simply fetch the Windows external libraries for UnrealIRCd package and extract the .zip to c:\dev\unrealircd-6-libs (in case of UnrealIRCd 6). This will result in directories like c:\dev\unrealircd-6-libs\libressl, c:\dev\unrealircd-6-libs\curl, etc.

Additional requirements
Put dlltool.exe (which is included in the windows external libraries package from above) somewhere in your path (eg: if you are lazy, simply put it in C:\WINDOWS\SYSTEM32)

Compiling UnrealIRCd 6
nmake -f Makefile.windows ^ LIBRESSL_INC_DIR="c:\dev\unrealircd-6-libs\libressl\include" ^ LIBRESSL_LIB_DIR="c:\dev\unrealircd-6-libs\libressl\lib" ^ SSLLIB="crypto-50.lib ssl-53.lib" ^ USE_REMOTEINC=1 ^ LIBCURL_INC_DIR="c:\dev\unrealircd-6-libs\curl\include" ^ LIBCURL_LIB_DIR="c:\dev\unrealircd-6-libs\curl\builds\libcurl-vc-x64-release-dll-ssl-dll-cares-dll-ipv6-obj-lib" ^ CARES_LIB_DIR="c:\dev\unrealircd-6-libs\c-ares\msvc\cares\dll-release" ^ CARES_INC_DIR="c:\dev\unrealircd-6-libs\c-ares\include" ^ CARESLIB="cares.lib" ^ PCRE2_INC_DIR="c:\dev\unrealircd-6-libs\pcre2\include" ^ PCRE2_LIB_DIR="c:\dev\unrealircd-6-libs\pcre2\lib" ^ PCRE2LIB="pcre2-8.lib" ^ ARGON2_LIB_DIR="c:\dev\unrealircd-6-libs\argon2\vs2015\build" ^ ARGON2_INC_DIR="c:\dev\unrealircd-6-libs\argon2\include" ^ ARGON2LIB="Argon2RefDll.lib" ^ SODIUM_LIB_DIR="c:\dev\unrealircd-6-libs\libsodium\bin\x64\Release\v142\dynamic" ^ SODIUM_INC_DIR="c:\dev\unrealircd-6-libs\libsodium\src\libsodium\include" ^ SODIUMLIB="libsodium.lib" ^ JANSSON_LIB_DIR="c:\dev\unrealircd-6-libs\jansson\lib" ^ JANSSON_INC_DIR="c:\dev\unrealircd-6-libs\jansson\include" ^ JANSSONLIB="jansson.lib" ^ GEOIPCLASSIC_LIB_DIR="c:\dev\unrealircd-6-libs\GeoIP\libGeoIP" ^ GEOIPCLASSIC_INC_DIR="c:\dev\unrealircd-6-libs\GeoIP\libGeoIP" ^ GEOIPCLASSICLIB="GeoIP.lib" %*
 * 1) Start the Developer Command Prompt: Start - Visual Studio 2019 - Visual Studio Tools - VC - x64 Native Tools Command Prompt for targeting x64
 * 2) Change to your UnrealIRCd compile directory, for example c:\dev\unrealircd-6.0.X
 * 3) Create a file build.bat and put the following text into it:

Now let's compile: build.bat build.bat SYMBOLFILE build.bat

It's normal for errors to appear the first time you run build.bat. You then run the command to update the SYMBOLFILE and then re-run build.bat.

Problems

 * Again, it's normal for build.bat to fail the first time. See last sentence of previous section.
 * If you get errors where the compiler/linker cannot find crypto-XX.lib or ssl-YY.lib then do a quick search in c:\dev for the correct version numbers and adjust your build.bat. Please report back to the UnrealIRCd team so we can update this wiki :)

Compiling modules
IMPORTANT: Before you do this, you first need to compile UnrealIRCd, see previous section(s).


 * 1) Start the developer command prompt (see previous section on how to do that)
 * 2) Change to your UnrealIRCd compile directory, for example c:\dev\unrealircd-6.0.X
 * 3) Put your module (the .c file) in src\modules\third, eg: c:\dev\unrealircd-6.0.X\src\modules\third\somemod.c
 * 4) From the main c:\dev\unrealircd-6.0.X directory run the build.bat file the following way: build.bat CUSTOMMODULE MODULEFILE=mymod Naturally, replace mymod with the name of your module (without .c suffix!)
 * 5) Done. You now have a DLL file in src\modules\third

In case you wonder, the way this works is that the build.bat contains  at the end of the file, which allows us to pass command line parameters to it.

Creating an installer
In case you want to create an installer:
 * Download and install Innosetup.
 * Open and build src\windows\unrealinst.iss
 * This will output to setup.exe, which you can distribute and run to install UnrealIRCd.