Building on Win 32 platforms
============================
31.7.1999, Sampo Kellomaki <sampo@iki..fi>
7.6.2002, reviewed and added comments, --Sampo
16.8.2002, added comments by Marcel Bucher --Sampo
10.7.2007. Complete rewrite to agree with latest version 1.31. References to
ancient versions and untested procedures removed --mikem
22.4.2010 Updated info for 64 bit versions --mikem
23.12.2022 Update OPENSSL_Applink for 1.93_02 and later --hvn
30.12.2023 Add Windows 11 23H2 notes --hvn

Notes: 

1. "no OPENSSL_Applink" runtime error
Changes in Net::SSLeay 1.93_02 fix this error with
Net::SSLeay::P_PKCS12_load_file and Net::SSLeay::CTX_use_PKCS12_file
functions. The error is caused when a file pointer or descriptor (FILE
*, POSIX/unix fd) is passed between boundaries, as described
below. Recommended fix is to use OpenSSL BIO API. Net::SSLeay still
exposes SSL_SESSION_print_fp() which expects a FILE * as its first
argument. See Net::SSLeay manual for more information about
Net::SSLeay::SESSION_print_fp() and a possible workaround.

Information for Net::SSLeay 1.93_01 and earlier follows:
With some combinations of Windows, perl, compiler and compiler options, you
may see a runtime error "no OPENSSL_Applink", when calling
Net::SSLeay::P_PKCS12_load_file. This appears to be due to incompatible
compile options between the openssl libraries and Net::SSLeay. In particular
it has been observed with Shining Light OpenSSL See
https://www.openssl.org/support/faq.html for more details. Alas, the
apparently simple and receommended solution of adding applink.c to the SSLeay
library does not work, since applink.c need to be in the .exe file, not the
.dll for this to work. Best workaround is to build and install OpenSSL for
windows yourself.

2. If your OpenSSL is installed in an unusual place, you can tell
Net-SSLeay where to find it with the OPENSSL_PREFIX environment
variable:
set OPENSSL_PREFIX=c:\OpenSSL-1.0.1c
perl Makefile.PL
make
.....

0. Windows 11 version 23H2
   Visual Studio Community 2022
   64bit and 32bit Perl 5.38.2 compiled with Visual Studio Community 2022
   Shining Light 64bit and 32bit OpenSSL 1.1.1w, 3.0.12, 3.1.4 and 3.2.0

Compile 64bit or 32bit Perl.
Install 64bit or 32bit Shining LightOpenSSL package.
Change to Net-SSLeay directory and do the following:
 perl Makefile.PL
 nmake
 nmake test
 nmake install

Caution: Static linking seem to require updating library names to use
_static suffix with the aforementioned Shining Light OpenSSL
versions. Run the following command after nmake to see which
libraries and symbols are required to be dynamically loaded:
  dumpbin /imports blib\arch\auto\Net\SSLeay\SSLeay.dll

Library names and locations for static linking seem to vary between
installation methods (local compilation, Shinging Light, other OpenSSL
installers). Therefore Makefile.PL may not be able to keep up with all
the possibilities.

Caution: When both 32bit and 64bit Shining Light (and possibly other)
OpenSSL package versions are installed, Makefile.PL may pick a wrong
location. Use OPENSSL_PREFIX environment variable in case of problems.

1. Windows Server 2003
   ActivePerl 5.8.8.820
   VC++ 6.0
   Microsoft Platform SDK SVR2003R2
   Shining Light Win32 OpenSSL 0.9.7L
      http://www.shininglightpro.com/products/Win32OpenSSL.html
   Dynamic linking to SSL DLLs

Install all packages in the order listed above
Unpack and install the Net-SSLeay package
 cd Net-SSLeay-xxxx
 perl Makefile.PL
 nmake
 nmake test
 nmake install

Caution. There is an issue with Shining Light Win32 OpenSSL 0.9.7m and 0.9.8e
on Server 2003: These versions were built with VC 7.1 and the packages are
missing the 7.1 runtime DLL. This means that the openssl binaries from those
versions will not run on a standard Server 2003 platform, and this prevents
Net-SSLeay being built. Shining Light say this problem will be fixed in later
versions, where they will revert to the earlier build procedures.

2. Windows Server 2003
   ActivePerl 5.8.8.820
   VC++ 6.0
   Microsoft Platform SDK SVR2003R2
   OpenSSL 0.9.8e source openssl-0.9.8e.tar.gz
   Dynamic linking to SSL DLLs

Install all packages in the order listed above
Unpack and build OpenSSL:
  cd openssl-0.9.8e
  perl Configure VC-WIN32 --prefix=c:/OpenSSL
  ms\do_ms
  nmake -f ms\ntdll.mak
  nmake -f ms\ntdll.mak install
(if you have trouble getting to this stage, consult INSTALL.W32)
  copy c:\OpenSSL\bin\*.dll c:\windows\system32

Unpack and install the Net-SSLeay package
 cd Net-SSLeay-xxxx
 perl Makefile.PL
 nmake
 copy c:\OpenSSL\bin\*.dll blib\arch\auto\Net\SSLeay\
 nmake test
 nmake install

3. Windows XP SP2 CAUTION: this is not working yet
   ActivePerl 5.8.8.820
   Visual Studio Express 2005
   Microsoft Platform SDK SVR2003R2
   OpenSSL 0.9.8e source openssl-0.9.8e.tar.gz
   Dynamic linking to SSL DLLs

- Install all packages in the order listed above (make sure you follow the
   instructions on the download page about adding the appropriate paths to the
   Projects and Solutions section of the Options dialog box, and updating
   corewin_express.vsprops file)
- Start a build shell with Start->All Programs->Microsoft Windows SDK->CMD Shell
- cd openssl-0.9.8e
- perl Configure VC-WIN32 --prefix=c:/OpenSSL
- ms\do_masm
- nmake -f ms\ntdll.mak
- nmake -f ms\ntdll.mak install
   (if you have trouble getting to this stage, consult INSTALL.W32)
- cd Net-SSLeay-xxxx
- perl Makefile.PL
- nmake
- copy c:\OpenSSL\bin\*.dll blib\arch\auto\Net\SSLeay\
- nmake test
  CAUTION: nmake test fails at this stage. Any suggestions?? This may be
   relevant: http://www.itwriting.com/blog/?postid=261&replyto=2542
- nmake install

4. Windows XP SP2
   Strawberry Perl 5.8.8-alpha-2
   OpenSSL 0.9.8e source openssl-0.9.8e.tar.gz

- Install Strawberry Perl by running the installer
  (strawberry-perl-5.8.8-alpha-2.exe in this example)
- Unpack openssl-0.9.8e.tar.gz
- cd openssl-0.9.8e
- ms\mingw32
- cd out
- ..\ms\test
   (if you have trouble getting to this stage, consult INSTALL.W32)
- md c:\openssl 
- md c:\openssl\bin
- md c:\openssl\lib
- md c:\openssl\include
- md c:\openssl\include\openssl
- copy /b inc32\openssl\*       c:\openssl\include\openssl
- copy /b out\libssl32.a c:\openssl\lib
- copy /b out\libeay32.a c:\openssl\lib
- copy /b libssl32.dll c:\openssl\bin
- copy /b libeay32.dll c:\openssl\bin
- copy /b out\openssl.exe  c:\openssl\bin
- cd Net-SSLeay-xxxx
- c:\strawberry-perl\perl\bin\perl Makefile.PL
- dmake
- copy c:\openssl\bin\*.dll blib/arch/auto/Net/SSLeay
- dmake install

4. Windows XP SP2
   Perl CamelPack perl-camelpack-5.8.7.exe
   Shining Light Win32 OpenSSL 0.9.7L
      http://www.shininglightpro.com/products/Win32OpenSSL.html

Install all packages in the order listed above
Unpack and install the Net-SSLeay package
 cd Net-SSLeay-xxxx
 perl Makefile.PL (accept external tests and extra CPAN installs)
 nmake
 nmake install

(Note that 'nmake test' does not seem to work with CamelPack 5.8.7)

5. Windows Server 2003
   ActivePerl 5.8.8.820
   VC++ 6.0
   Microsoft Platform SDK SVR2003R2
   OpenSSL 0.9.8e source openssl-0.9.8e.tar.gz + tls extensions patch 
    from Radiator/goodies/openssl-0.9.8e-session-ticket-osc.patch   
   Dynamic linking to SSL DLLs

Install all packages in the order listed above
Unpack, patch and  and build OpenSSL, patch with 
  cd openssl-0.9.8e+extensions
  patch -p1 < Radiator/goodies/openssl-0.9.8e-session-ticket-osc.patch                 
  perl Configure VC-WIN32 --prefix=c:/OpenSSL enable-tlsext
  ms\do_ms
  nmake -f ms\ntdll.mak
  nmake -f ms\ntdll.mak install
(if you have trouble getting to this stage, consult INSTALL.W32)
  copy c:\OpenSSL\bin\*.dll c:\windows\system32

Unpack and install the Net-SSLeay package
 cd Net-SSLeay-xxxx
 perl Makefile.PL
 nmake
 copy c:\OpenSSL\bin\*.dll blib\arch\auto\Net\SSLeay\
 nmake test
 nmake install

6. Windows Server 2003
   ActivePerl 5.10.1
   Microsoft Platform SDK 2003 SP1
   OpenSSL 0.9.8i source including TLS extensions
   Dynamic linking to SSL DLLs

Build OpenSSL
   S:
   cd \openssl-0.9.8i+extensions
   nmake -f ms\ntdll.mak clean
   perl Configure VC-WIN64A --prefix=c:/OpenSSL enable-tlsext
   ms\do_win64a
   nmake -f ms\ntdll.mak
   cd out32dll
   ..\ms\test
   nmake -f ms\ntdll.mak install
Now build Net-SSLeay
   nmake clean
   R:
   cd \net-ssleay\trunk
   perl Makefile.PL
   nmake
   copy c:\OpenSSL\bin\*.dll blib\arch\auto\Net\SSLeay
   nmake test
   nmake install

7. Windows XP Professional SP3
  ActivePerl 5.16.1
  OpenSSL 1.0.1j binary from http://slproweb.com/download/Win32OpenSSL-1_0_1j.exe
  Visual C++ 2008 Redistributables from http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF
  Microsoft Visual Studio 2010 Express
   with Visual Studio Command Prompt shell:
   R:
   cd \net-ssleay\trunk
   perl Makefile.PL
   nmake
   nmake test (some warnings will be reported)

8. Windows XP Professional SP3 on VMWare
  ActivePerl 5.16.1
  OpenSSL 1.0.1 source code
  Microsoft Visual Studio 2010 Express
   with Visual Studio Command Prompt shell:
Build OpenSSL
   S:
   cd \openssl-1.0.1e
   perl Configure VC-WIN32 no-asm --prefix=c:/OpenSSL 
   ms\do_ms
   nmake -f ms\ntdll.mak
   nmake -f ms\ntdll.mak install
Now build Net-SSLeay
   R:
   cd \net-ssleay\trunk
   nmake clean
   perl Makefile.PL
   nmake
   nmake test (some warnings will be reported)
