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 2012 (also called Visual Studio 11.x).

You can download and install Visual Studio 2015 community edition (if you are eligible for it, most people are):
 * 1) Download and install Visual Studio 2015 from https://www.visualstudio.com/downloads/
 * 2) Whenever you need to compile something we say 'Start the Visual Studio .NET Command Prompt' below. You will have to do this via: Start - Visual Studio 2015 - Developer Command Prompt for VS2015. Once the CMD window is up, be sure to change the environment to x86 by typing SETENV /x86.
 * 3) Download https://www.unrealircd.org/files/dev/win/dlltool.exe and put the file somewhere in your path (simply put it in C:\WINDOWS\SYSTEM32)

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

External libraries
Fetch the Windows external libraries for UnrealIRCd and extract them all to c:\dev

Compiling
''NOTE: For 4.0.9 and 4.0.10 the compile script assume visual studio 2015. In reality I, and possibly others, still build with 2012 due to some problems or license restrictions. If you wish to build with Visual Studio 2012 then you will have to apply this patch prior to the steps below. (Extract to c:\dev and then run ..\rollback.bat while you are in the c:\dev\unrealircd-4.0.XX directory. Requires patch.exe.)''

'''TODO: The notes are not entirely up to date. The macros/defines below work only with the rollback patch from above! FIXME!'''

nmake -f makefile.win32 USE_SSL=1 OPENSSL_INC_DIR="C:\dev\libressl\include" OPENSSL_LIB_DIR="C:\dev\libressl\x86" 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\msvc110\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\build" PCRE2_LIB_DIR="c:\dev\pcre2\build\release" PCRE2LIB="pcre2-8.lib" nmake -f makefile.win32 SYMBOLFILE nmake -f makefile.win32 USE_SSL=1 OPENSSL_INC_DIR="C:\dev\libressl\include" OPENSSL_LIB_DIR="C:\dev\libressl\x86" 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\msvc110\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\build" PCRE2_LIB_DIR="c:\dev\pcre2\build\release" PCRE2LIB="pcre2-8.lib"
 * 1) Start the Visual Studio .NET Command Prompt
 * 2) Be sure to run SETENV /x86 if necessary
 * 3) Change to your UnrealIRCd compile directory, for example c:\dev\unrealircd-4.0.X
 * 4) Use the following nmake command:

Compiling modules
Note: you'll need to compile UnrealIRCd first, see previous step.


 * 1) Start the Visual Studio .NET Command Prompt
 * 2) Be sure to run SETENV /x86 if necessary
 * 3) Change to your UnrealIRCd compile directory, for example c:\dev\unrealircd-4.0.X
 * 4) Put your module (the .c file) in src\modules\third, eg: c:\dev\unrealircd-4.0.X\src\modules\third\somemod.c
 * 5) Use the same build command as with  but add the following at the end of the long line: CUSTOMMODULE MODULEFILE=somemod With this we mean: nmake -f makefile.win32 USE_SSL=1 OPENSSL_INC_DIR="C:\dev\libressl\include" ...etc. etc.... CUSTOMMODULE MODULEFILE=somemod
 * 6) Done. You have a DLL file.