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
Starting with UnrealIRCd 4.2.0 the official UnrealIRCd releases are compiled with Visual Studio 2017 (also called Visual Studio 15.x). We suggest you use this version too. The compiler can be downloaded free of charge for personal use via https://visualstudio.microsoft.com/

If you are compiling for an older version (4.0.x) then have a look at the wiki history of this page.

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

Additional requirements
Download https://www.unrealircd.org/files/dev/win/dlltool.exe and put the file somewhere in your path (eg: simply put it in C:\WINDOWS\SYSTEM32)

External libraries
Fetch the Windows external libraries for UnrealIRCd package and extract the .zip to c:\dev. This will result in directories like c:\dev\libressl, c:\dev\curl-ssl, c:\dev\pcre2, etc.

Compiling
nmake -f makefile.win32 ^ LIBRESSL_INC_DIR="c:\dev\libressl\include" ^ LIBRESSL_LIB_DIR="c:\dev\libressl\lib" ^ SSLLIB="crypto-44.lib ssl-46.lib" ^ USE_REMOTEINC=1 ^ LIBCURL_INC_DIR="c:\dev\curl-ssl\include" ^ LIBCURL_LIB_DIR="c:\dev\curl-ssl\builds\libcurl-vc-x86-release-dll-ssl-dll-ipv6-sspi-obj-lib" ^ CARES_LIB_DIR="c:\dev\c-ares\msvc\cares\dll-release" ^ CARES_INC_DIR="c:\dev\c-ares" ^ CARESLIB="cares.lib" ^ TRE_LIB_DIR="c:\dev\tre\win32\release" ^ TRE_INC_DIR="c:\dev\tre" ^ TRELIB="tre.lib" ^ PCRE2_INC_DIR="c:\dev\pcre2\include" ^ PCRE2_LIB_DIR="c:\dev\pcre2\lib" ^ PCRE2LIB="pcre2-8.lib" ^ %*
 * 1) Start the Developer Command Prompt: Start - Visual Studio 2017 - Visual Studio Tools - VC - x86 Native Tools Command Prompt for targeting x86
 * 2) Change to your UnrealIRCd compile directory, for example c:\dev\unrealircd-4.2.X
 * 3) Create a file build.bat and put the following text into it:

Now let's compile: build.bat nmake -f makefile.win32 SYMBOLFILE build.bat

It's normal for errors to appear the first time you run build.bat. You then run the nmake 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
Note: you'll need to compile UnrealIRCd first, see previous step.


 * 1) Start the developer prompt (see previous section on how to do that)
 * 2) Change to your UnrealIRCd compile directory, for example c:\dev\unrealircd-4.2.X
 * 3) Put your module (the .c file) in src\modules\third, eg: c:\dev\unrealircd-4.2.X\src\modules\third\somemod.c
 * 4) From the main c:\dev\unrealircd-4.2.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 have a DLL file (in src\modules\third)

The way this works is that the build.bat contains %* at the end which allows us to pass parameters to it.