Blame NOTES.WIN

Packit c4476c
Packit c4476c
 NOTES FOR THE WINDOWS PLATFORMS
Packit c4476c
 ===============================
Packit c4476c
Packit c4476c
 Windows targets can be classified as "native", ones that use Windows API
Packit c4476c
 directly, and "hosted" which rely on POSIX-compatible layer. "Native"
Packit c4476c
 targets are VC-* (where "VC" stems from abbreviating Microsoft Visual C
Packit c4476c
 compiler) and mingw[64]. "Hosted" platforms are Cygwin and MSYS[2]. Even
Packit c4476c
 though the latter is not directly supported by OpenSSL Team, it's #1
Packit c4476c
 popular choice for building MinGW targets. In the nutshell MinGW builds
Packit c4476c
 are always cross-compiled. On Linux and Cygwin they look exactly as such
Packit c4476c
 and require --cross-compile-prefix option. While on MSYS[2] it's solved
Packit c4476c
 rather by placing gcc that produces "MinGW binary" code 1st on $PATH.
Packit c4476c
 This is customarily source of confusion. "Hosted" applications "live" in
Packit c4476c
 emulated file system name space with POSIX-y root, mount points, /dev
Packit c4476c
 and even /proc. Confusion is intensified by the fact that MSYS2 shell
Packit c4476c
 (or rather emulated execve(2) call) examines the binary it's about to
Packit c4476c
 start, and if it's found *not* to be linked with MSYS2 POSIX-y thing,
Packit c4476c
 command line arguments that look like file names get translated from
Packit c4476c
 emulated name space to "native". For example '/c/some/where' becomes
Packit c4476c
 'c:\some\where', '/dev/null' - 'nul'. This creates an illusion that
Packit c4476c
 there is no difference between MSYS2 shell and "MinGW binary", but
Packit c4476c
 there is. Just keep in mind that "MinGW binary" "experiences" Windows
Packit c4476c
 system in exactly same way as one produced by VC, and in its essence
Packit c4476c
 is indistinguishable from the latter. (Which by the way is why
Packit c4476c
 it's referred to in quotes here, as "MinGW binary", it's just as
Packit c4476c
 "native" as it can get.)
Packit c4476c
Packit c4476c
 Visual C++ builds, a.k.a. VC-*
Packit c4476c
 ==============================
Packit c4476c
Packit c4476c
 Requirement details
Packit c4476c
 -------------------
Packit c4476c
Packit c4476c
 In addition to the requirements and instructions listed in INSTALL,
Packit c4476c
 these are required as well:
Packit c4476c
Packit c4476c
 - Perl. We recommend ActiveState Perl, available from
Packit c4476c
   https://www.activestate.com/ActivePerl. Another viable alternative
Packit c4476c
   appears to be Strawberry Perl, http://strawberryperl.com.
Packit c4476c
   You also need the perl module Text::Template, available on CPAN.
Packit c4476c
   Please read NOTES.PERL for more information.
Packit c4476c
Packit c4476c
 - Microsoft Visual C compiler. Since we can't test them all, there is
Packit c4476c
   unavoidable uncertainty about which versions are supported. Latest
Packit c4476c
   version along with couple of previous are certainly supported. On
Packit c4476c
   the other hand oldest one is known not to work. Everything between
Packit c4476c
   falls into best-effort category.
Packit c4476c
Packit c4476c
 - Netwide Assembler, a.k.a. NASM, available from https://www.nasm.us,
Packit c4476c
   is required. Note that NASM is the only supported assembler. Even
Packit c4476c
   though Microsoft provided assembler is NOT supported, contemporary
Packit c4476c
   64-bit version is exercised through continuous integration of
Packit c4476c
   VC-WIN64A-masm target.
Packit c4476c
Packit c4476c
Packit c4476c
 Installation directories
Packit c4476c
 ------------------------
Packit c4476c
Packit c4476c
 The default installation directories are derived from environment
Packit c4476c
 variables.
Packit c4476c
Packit c4476c
 For VC-WIN32, the following defaults are use:
Packit c4476c
Packit c4476c
     PREFIX:      %ProgramFiles(86)%\OpenSSL
Packit c4476c
     OPENSSLDIR:  %CommonProgramFiles(86)%\SSL
Packit c4476c
Packit c4476c
 For VC-WIN64, the following defaults are use:
Packit c4476c
Packit c4476c
     PREFIX:      %ProgramW6432%\OpenSSL
Packit c4476c
     OPENSSLDIR:  %CommonProgramW6432%\SSL
Packit c4476c
Packit c4476c
 Should those environment variables not exist (on a pure Win32
Packit c4476c
 installation for examples), these fallbacks are used:
Packit c4476c
Packit c4476c
     PREFIX:      %ProgramFiles%\OpenSSL
Packit c4476c
     OPENSSLDIR:  %CommonProgramFiles%\SSL
Packit c4476c
Packit c4476c
 ALSO NOTE that those directories are usually write protected, even if
Packit c4476c
 your account is in the Administrators group.  To work around that,
Packit c4476c
 start the command prompt by right-clicking on it and choosing "Run as
Packit c4476c
 Administrator" before running 'nmake install'.  The other solution
Packit c4476c
 is, of course, to choose a different set of directories by using
Packit c4476c
 --prefix and --openssldir when configuring.
Packit c4476c
Packit c4476c
 mingw and mingw64
Packit c4476c
 =================
Packit c4476c
Packit c4476c
 * MSYS2 shell and development environment installation:
Packit c4476c
Packit c4476c
   Download MSYS2 from https://msys2.github.io/ and follow installation
Packit c4476c
   instructions. Once up and running install even make, perl, (git if
Packit c4476c
   needed,) mingw-w64-i686-gcc and/or mingw-w64-x86_64-gcc. You should
Packit c4476c
   have corresponding MinGW items on your start menu, use *them*, not
Packit c4476c
   generic MSYS2. As implied in opening note, difference between them
Packit c4476c
   is which compiler is found 1st on $PATH. At this point ./config
Packit c4476c
   should recognize correct target, roll as if it was Unix...
Packit c4476c
Packit c4476c
 * It is also possible to build mingw[64] on Linux or Cygwin by
Packit c4476c
   configuring with corresponding --cross-compile-prefix= option. For
Packit c4476c
   example
Packit c4476c
Packit c4476c
     ./Configure mingw --cross-compile-prefix=i686-w64-mingw32- ...
Packit c4476c
Packit c4476c
   or
Packit c4476c
Packit c4476c
     ./Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32- ...
Packit c4476c
Packit c4476c
   This naturally implies that you've installed corresponding add-on
Packit c4476c
   packages.
Packit c4476c
Packit c4476c
 Independently of the method chosen to build for mingw, the installation
Packit c4476c
 paths are similar to those used when building with VC-* targets, except
Packit c4476c
 that in case the fallbacks mentioned there aren't possible (typically
Packit c4476c
 when cross compiling on Linux), the paths will be the following:
Packit c4476c
Packit c4476c
 For mingw:
Packit c4476c
Packit c4476c
     PREFIX:      C:/Program Files (x86)/OpenSSL
Packit c4476c
     OPENSSLDIR   C:/Program Files (x86)/Common Files/SSL
Packit c4476c
Packit c4476c
 For mingw64:
Packit c4476c
Packit c4476c
     PREFIX:      C:/Program Files/OpenSSL
Packit c4476c
     OPENSSLDIR   C:/Program Files/Common Files/SSL
Packit c4476c
Packit c4476c
 Linking your application
Packit c4476c
 ========================
Packit c4476c
Packit c4476c
 This section applies to all "native" builds.
Packit c4476c
Packit c4476c
 If you link with static OpenSSL libraries then you're expected to
Packit c4476c
 additionally link your application with WS2_32.LIB, GDI32.LIB,
Packit c4476c
 ADVAPI32.LIB, CRYPT32.LIB and USER32.LIB. Those developing
Packit c4476c
 non-interactive service applications might feel concerned about
Packit c4476c
 linking with GDI32.LIB and USER32.LIB, as they are justly associated
Packit c4476c
 with interactive desktop, which is not available to service
Packit c4476c
 processes. The toolkit is designed to detect in which context it's
Packit c4476c
 currently executed, GUI, console app or service, and act accordingly,
Packit c4476c
 namely whether or not to actually make GUI calls. Additionally those
Packit c4476c
 who wish to /DELAYLOAD:GDI32.DLL and /DELAYLOAD:USER32.DLL and
Packit c4476c
 actually keep them off service process should consider implementing
Packit c4476c
 and exporting from .exe image in question own _OPENSSL_isservice not
Packit c4476c
 relying on USER32.DLL. E.g., on Windows Vista and later you could:
Packit c4476c
Packit c4476c
	__declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void)
Packit c4476c
	{   DWORD sess;
Packit c4476c
	    if (ProcessIdToSessionId(GetCurrentProcessId(),&sess))
Packit c4476c
	        return sess==0;
Packit c4476c
	    return FALSE;
Packit c4476c
	}
Packit c4476c
Packit c4476c
 If you link with OpenSSL .DLLs, then you're expected to include into
Packit c4476c
 your application code small "shim" snippet, which provides glue between
Packit c4476c
 OpenSSL BIO layer and your compiler run-time. See the OPENSSL_Applink
Packit c4476c
 manual page for further details.
Packit c4476c
Packit c4476c
 Cygwin, "hosted" environment
Packit c4476c
 ============================
Packit c4476c
Packit c4476c
 Cygwin implements a Posix/Unix runtime system (cygwin1.dll) on top of the
Packit c4476c
 Windows subsystem and provides a bash shell and GNU tools environment.
Packit c4476c
 Consequently, a make of OpenSSL with Cygwin is virtually identical to the
Packit c4476c
 Unix procedure.
Packit c4476c
Packit c4476c
 To build OpenSSL using Cygwin, you need to:
Packit c4476c
Packit c4476c
 * Install Cygwin (see https://cygwin.com/)
Packit c4476c
Packit c4476c
 * Install Cygwin Perl and ensure it is in the path. Recall that
Packit c4476c
   as least 5.10.0 is required.
Packit c4476c
Packit c4476c
 * Run the Cygwin bash shell
Packit c4476c
Packit c4476c
 Apart from that, follow the Unix instructions in INSTALL.
Packit c4476c
Packit c4476c
 NOTE: "make test" and normal file operations may fail in directories
Packit c4476c
 mounted as text (i.e. mount -t c:\somewhere /home) due to Cygwin
Packit c4476c
 stripping of carriage returns. To avoid this ensure that a binary
Packit c4476c
 mount is used, e.g. mount -b c:\somewhere /home.