NOTES.WIN 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. NOTES FOR THE WINDOWS PLATFORMS
  2. ===============================
  3. Windows targets can be classified as "native", ones that use Windows API
  4. directly, and "hosted" which rely on POSIX-compatible layer. "Native"
  5. targets are VC-* (where "VC" stems from abbreviating Microsoft Visual C
  6. compiler) and mingw[64]. "Hosted" platforms are Cygwin and MSYS[2]. Even
  7. though the latter is not directly supported by OpenSSL Team, it's #1
  8. popular choice for building MinGW targets. In the nutshell MinGW builds
  9. are always cross-compiled. On Linux and Cygwin they look exactly as such
  10. and require --cross-compile-prefix option. While on MSYS[2] it's solved
  11. rather by placing gcc that produces "MinGW binary" code 1st on $PATH.
  12. This is customarily source of confusion. "Hosted" applications "live" in
  13. emulated filesystem name space with POSIX-y root, mount points, /dev
  14. and even /proc. Confusion is intensified by the fact that MSYS2 shell
  15. (or rather emulated execve(2) call) examines the binary it's about to
  16. start, and if it's found *not* to be linked with MSYS2 POSIX-y thing,
  17. command line arguments that look like filenames get translated from
  18. emulated name space to "native". For example '/c/some/where' becomes
  19. 'c:\some\where', '/dev/null' - 'nul'. This creates an illusion that
  20. there is no difference between MSYS2 shell and "MinGW binary", but
  21. there is. Just keep in mind that "MinGW binary" "experiences" Windows
  22. system in exactly same way as one produced by VC, and in its essence
  23. is indistinguishable from the latter. (Which by the way is why
  24. it's referred to in quotes here, as "MinGW binary", it's just as
  25. "native" as it can get.)
  26. Visual C++ builds, aka VC-*
  27. ==============================
  28. Requirement details
  29. -------------------
  30. In addition to the requirements and instructions listed in INSTALL,
  31. these are required as well:
  32. - Perl. We recommend ActiveState Perl, available from
  33. https://www.activestate.com/ActivePerl. Another viable alternative
  34. appears to be Strawberry Perl, http://strawberryperl.com.
  35. You also need the perl module Text::Template, available on CPAN.
  36. Please read NOTES.PERL for more information.
  37. - Microsoft Visual C compiler. Since we can't test them all, there is
  38. unavoidable uncertainty about which versions are supported. Latest
  39. version along with couple of previous are certainly supported. On
  40. the other hand oldest one is known not to work. Everything between
  41. falls into best-effort category.
  42. - Netwide Assembler, aka NASM, available from https://www.nasm.us,
  43. is required. Note that NASM is the only supported assembler. Even
  44. though Microsoft provided assembler is NOT supported, contemporary
  45. 64-bit version is exercised through continuous integration of
  46. VC-WIN64A-masm target.
  47. Installation directories
  48. ------------------------
  49. The default installation directories are derived from environment
  50. variables.
  51. For VC-WIN32, the following defaults are use:
  52. PREFIX: %ProgramFiles(x86)%\OpenSSL
  53. OPENSSLDIR: %CommonProgramFiles(x86)%\SSL
  54. For VC-WIN64, the following defaults are use:
  55. PREFIX: %ProgramW6432%\OpenSSL
  56. OPENSSLDIR: %CommonProgramW6432%\SSL
  57. Should those environment variables not exist (on a pure Win32
  58. installation for examples), these fallbacks are used:
  59. PREFIX: %ProgramFiles%\OpenSSL
  60. OPENSSLDIR: %CommonProgramFiles%\SSL
  61. ALSO NOTE that those directories are usually write protected, even if
  62. your account is in the Administrators group. To work around that,
  63. start the command prompt by right-clicking on it and choosing "Run as
  64. Administrator" before running 'nmake install'. The other solution
  65. is, of course, to choose a different set of directories by using
  66. --prefix and --openssldir when configuring.
  67. mingw and mingw64
  68. =================
  69. * MSYS2 shell and development environment installation:
  70. Download MSYS2 from https://msys2.github.io/ and follow installation
  71. instructions. Once up and running install even make, perl, (git if
  72. needed,) mingw-w64-i686-gcc and/or mingw-w64-x86_64-gcc. You should
  73. have corresponding MinGW items on your start menu, use *them*, not
  74. generic MSYS2. As implied in opening note, difference between them
  75. is which compiler is found 1st on $PATH. At this point ./config
  76. should recognize correct target, roll as if it was Unix...
  77. * It is also possible to build mingw[64] on Linux or Cygwin by
  78. configuring with corresponding --cross-compile-prefix= option. For
  79. example
  80. ./Configure mingw --cross-compile-prefix=i686-w64-mingw32- ...
  81. or
  82. ./Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32- ...
  83. This naturally implies that you've installed corresponding add-on
  84. packages.
  85. Independently of the method chosen to build for mingw, the installation
  86. paths are similar to those used when building with VC-* targets, except
  87. that in case the fallbacks mentioned there aren't possible (typically
  88. when cross compiling on Linux), the paths will be the following:
  89. For mingw:
  90. PREFIX: C:/Program Files (x86)/OpenSSL
  91. OPENSSLDIR C:/Program Files (x86)/Common Files/SSL
  92. For mingw64:
  93. PREFIX: C:/Program Files/OpenSSL
  94. OPENSSLDIR C:/Program Files/Common Files/SSL
  95. Linking your application
  96. ========================
  97. This section applies to all "native" builds.
  98. If you link with static OpenSSL libraries then you're expected to
  99. additionally link your application with WS2_32.LIB, GDI32.LIB,
  100. ADVAPI32.LIB, CRYPT32.LIB and USER32.LIB. Those developing
  101. noninteractive service applications might feel concerned about
  102. linking with GDI32.LIB and USER32.LIB, as they are justly associated
  103. with interactive desktop, which is not available to service
  104. processes. The toolkit is designed to detect in which context it's
  105. currently executed, GUI, console app or service, and act accordingly,
  106. namely whether or not to actually make GUI calls. Additionally those
  107. who wish to /DELAYLOAD:GDI32.DLL and /DELAYLOAD:USER32.DLL and
  108. actually keep them off service process should consider implementing
  109. and exporting from .exe image in question own _OPENSSL_isservice not
  110. relying on USER32.DLL. E.g., on Windows Vista and later you could:
  111. __declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void)
  112. { DWORD sess;
  113. if (ProcessIdToSessionId(GetCurrentProcessId(),&sess))
  114. return sess==0;
  115. return FALSE;
  116. }
  117. If you link with OpenSSL .DLLs, then you're expected to include into
  118. your application code small "shim" snippet, which provides glue between
  119. OpenSSL BIO layer and your compiler run-time. See the OPENSSL_Applink
  120. manual page for further details.
  121. Cygwin, "hosted" environment
  122. ============================
  123. Cygwin implements a Posix/Unix runtime system (cygwin1.dll) on top of the
  124. Windows subsystem and provides a bash shell and GNU tools environment.
  125. Consequently, a make of OpenSSL with Cygwin is virtually identical to the
  126. Unix procedure.
  127. To build OpenSSL using Cygwin, you need to:
  128. * Install Cygwin (see https://cygwin.com/)
  129. * Install Cygwin Perl and ensure it is in the path. Recall that
  130. as least 5.10.0 is required.
  131. * Run the Cygwin bash shell
  132. Apart from that, follow the Unix instructions in INSTALL.
  133. NOTE: "make test" and normal file operations may fail in directories
  134. mounted as text (i.e. mount -t c:\somewhere /home) due to Cygwin
  135. stripping of carriage returns. To avoid this ensure that a binary
  136. mount is used, e.g. mount -b c:\somewhere /home.