]>
Commit | Line | Data |
---|---|---|
dc589dae | 1 | Notes for Windows platforms |
474853c3 | 2 | =========================== |
26abc8f0 | 3 | |
dc589dae DMSP |
4 | - [Native builds using Visual C++](#native-builds-using-visual-c++) |
5 | - [Native builds using MinGW](#native-builds-using-mingw) | |
6 | - [Linking native applications](#linking-native-applications) | |
7 | - [Hosted builds using Cygwin](#hosted-builds-using-cygwin) | |
df4c1d80 | 8 | |
df4c1d80 | 9 | |
dc589dae | 10 | There are various options to build and run OpenSSL on the Windows platforms. |
df4c1d80 | 11 | |
dc589dae DMSP |
12 | "Native" OpenSSL uses the Windows APIs directly at run time. |
13 | To build a native OpenSSL you can either use: | |
df4c1d80 | 14 | |
dc589dae DMSP |
15 | Microsoft Visual C++ (MSVC) C compiler on the command line |
16 | or | |
17 | MinGW cross compiler | |
18 | run on the GNU-like development environment MSYS2 | |
19 | or run on Linux or Cygwin | |
97a479c6 | 20 | |
dc589dae DMSP |
21 | "Hosted" OpenSSL relies on an external POSIX compatibility layer |
22 | for building (using GNU/Unix shell, compiler, and tools) and at run time. | |
23 | For this option you can use Cygwin. | |
26abc8f0 | 24 | |
dc589dae DMSP |
25 | Native builds using Visual C++ |
26 | ============================== | |
07930a75 | 27 | |
dc589dae | 28 | The native builds using Visual C++ have a VC-* prefix. |
df4c1d80 | 29 | |
dc589dae DMSP |
30 | Requirement details |
31 | ------------------- | |
df4c1d80 | 32 | |
dc589dae DMSP |
33 | In addition to the requirements and instructions listed in INSTALL.md, |
34 | these are required as well: | |
df4c1d80 | 35 | |
dc589dae DMSP |
36 | ### Perl |
37 | ||
38 | We recommend Strawberry Perl, available from <http://strawberryperl.com/> | |
39 | Please read NOTES.PERL for more information, including the use of CPAN. | |
40 | An alternative is ActiveState Perl, <https://www.activestate.com/ActivePerl> | |
41 | for which you may need to explicitly build the Perl module Win32/Console.pm | |
42 | via <https://platform.activestate.com/ActiveState> and then download it. | |
43 | ||
44 | ### Microsoft Visual C compiler. | |
45 | ||
46 | Since these are proprietary and ever-changing we cannot test them all. | |
47 | Older versions may not work. Use a recent version wherever possible. | |
48 | ||
49 | ### Netwide Assembler (NASM) | |
50 | ||
51 | NASM is the only supported assembler. It is available from <https://www.nasm.us>. | |
52 | ||
53 | Quick start | |
54 | ----------- | |
df4c1d80 DDO |
55 | |
56 | 1. Install Perl | |
57 | ||
58 | 2. Install NASM | |
59 | ||
60 | 3. Make sure both Perl and NASM are on your %PATH% | |
61 | ||
62 | 4. Use Visual Studio Developer Command Prompt with administrative privileges, | |
63 | choosing one of its variants depending on the intended architecture. | |
64 | Or run "cmd" and execute "vcvarsall.bat" with one of the options x86, | |
65 | x86_amd64, x86_arm, x86_arm64, amd64, amd64_x86, amd64_arm, or amd64_arm64. | |
66 | This sets up the environment variables needed for nmake.exe, cl.exe, etc. | |
474853c3 RS |
67 | See also |
68 | <https://docs.microsoft.com/cpp/build/building-on-the-command-line> | |
df4c1d80 DDO |
69 | |
70 | 5. From the root of the OpenSSL source directory enter | |
71 | perl Configure VC-WIN32 if you want 32-bit OpenSSL or | |
16328e9f RL |
72 | perl Configure VC-WIN64A if you want 64-bit OpenSSL or |
73 | perl Configure to let Configure figure out the platform | |
df4c1d80 DDO |
74 | |
75 | 6. nmake | |
3189772e | 76 | |
df4c1d80 | 77 | 7. nmake test |
26abc8f0 | 78 | |
df4c1d80 | 79 | 8. nmake install |
26abc8f0 | 80 | |
dc589dae DMSP |
81 | For the full installation instructions, or if anything goes wrong at any stage, |
82 | check the INSTALL.md file. | |
b32b8961 | 83 | |
dc589dae DMSP |
84 | Installation directories |
85 | ------------------------ | |
8c16829e | 86 | |
dc589dae DMSP |
87 | The default installation directories are derived from environment |
88 | variables. | |
8c16829e | 89 | |
dc589dae | 90 | For VC-WIN32, the following defaults are use: |
8c16829e | 91 | |
70f23648 JS |
92 | PREFIX: %ProgramFiles(x86)%\OpenSSL |
93 | OPENSSLDIR: %CommonProgramFiles(x86)%\SSL | |
8c16829e | 94 | |
dc589dae | 95 | For VC-WIN64, the following defaults are use: |
8c16829e | 96 | |
dc589dae DMSP |
97 | PREFIX: %ProgramW6432%\OpenSSL |
98 | OPENSSLDIR: %CommonProgramW6432%\SSL | |
8c16829e | 99 | |
dc589dae DMSP |
100 | Should those environment variables not exist (on a pure Win32 |
101 | installation for examples), these fallbacks are used: | |
8c16829e | 102 | |
dc589dae DMSP |
103 | PREFIX: %ProgramFiles%\OpenSSL |
104 | OPENSSLDIR: %CommonProgramFiles%\SSL | |
8c16829e | 105 | |
dc589dae DMSP |
106 | ALSO NOTE that those directories are usually write protected, even if |
107 | your account is in the Administrators group. To work around that, | |
108 | start the command prompt by right-clicking on it and choosing "Run as | |
109 | Administrator" before running 'nmake install'. The other solution | |
110 | is, of course, to choose a different set of directories by using | |
111 | --prefix and --openssldir when configuring. | |
8c16829e | 112 | |
dc589dae DMSP |
113 | Special notes for Universal Windows Platform builds, aka VC-*-UWP |
114 | -------------------------------------------------------------------- | |
5ded1ca6 M |
115 | |
116 | - UWP targets only support building the static and dynamic libraries. | |
117 | ||
5ded1ca6 M |
118 | - You should define the platform type to "uwp" and the target arch via |
119 | "vcvarsall.bat" before you compile. For example, if you want to build | |
df4c1d80 | 120 | "arm64" builds, you should run "vcvarsall.bat x86_arm64 uwp". |
5ded1ca6 | 121 | |
dc589dae DMSP |
122 | Native builds using MinGW |
123 | ========================= | |
3e67b333 | 124 | |
dc589dae | 125 | MinGW offers an alternative way to build native OpenSSL, by cross compilation. |
b32b8961 | 126 | |
df4c1d80 | 127 | * Usually the build is done on Windows in a GNU-like environment called MSYS2. |
b32b8961 | 128 | |
df4c1d80 DDO |
129 | MSYS2 provides GNU tools, a Unix-like command prompt, |
130 | and a UNIX compatibility layer for applications. | |
8c1cbc72 | 131 | However, in this context it is only used for building OpenSSL. |
df4c1d80 DDO |
132 | The resulting OpenSSL does not rely on MSYS2 to run and is fully native. |
133 | ||
134 | Requirement details | |
135 | ||
474853c3 | 136 | - MSYS2 shell, from <https://www.msys2.org/> |
df4c1d80 DDO |
137 | |
138 | - Perl, at least version 5.10.0, which usually comes pre-installed with MSYS2 | |
139 | ||
140 | - make, installed using "pacman -S make" into the MSYS2 environment | |
141 | ||
142 | - MinGW[64] compiler: mingw-w64-i686-gcc and/or mingw-w64-x86_64-gcc. | |
143 | These compilers must be on your MSYS2 $PATH. | |
144 | A common error is to not have these on your $PATH. | |
145 | The MSYS2 version of gcc will not work correctly here. | |
146 | ||
147 | In the MSYS2 shell do the configuration depending on the target architecture: | |
b32b8961 | 148 | |
dc589dae | 149 | ./Configure mingw ... |
97a479c6 | 150 | or |
dc589dae | 151 | ./Configure mingw64 ... |
df4c1d80 | 152 | or |
dc589dae DMSP |
153 | ./Configure ... |
154 | ||
df4c1d80 DDO |
155 | for the default architecture. |
156 | ||
157 | Apart from that, follow the Unix / Linux instructions in INSTALL.md. | |
158 | ||
159 | * It is also possible to build mingw[64] on Linux or Cygwin. | |
160 | ||
161 | In this case configure with the corresponding --cross-compile-prefix= option. | |
162 | For example | |
b32b8961 | 163 | |
dc589dae | 164 | ./Configure mingw --cross-compile-prefix=i686-w64-mingw32- ... |
df4c1d80 | 165 | or |
dc589dae | 166 | ./Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32- ... |
b32b8961 | 167 | |
df4c1d80 DDO |
168 | This requires that you've installed the necessary add-on packages for |
169 | mingw[64] cross compilation. | |
b32b8961 | 170 | |
dc589dae DMSP |
171 | Linking native applications |
172 | =========================== | |
173 | ||
174 | This section applies to all native builds. | |
175 | ||
176 | If you link with static OpenSSL libraries then you're expected to | |
177 | additionally link your application with WS2_32.LIB, GDI32.LIB, | |
178 | ADVAPI32.LIB, CRYPT32.LIB and USER32.LIB. Those developing | |
179 | non-interactive service applications might feel concerned about | |
180 | linking with GDI32.LIB and USER32.LIB, as they are justly associated | |
181 | with interactive desktop, which is not available to service | |
182 | processes. The toolkit is designed to detect in which context it's | |
183 | currently executed, GUI, console app or service, and act accordingly, | |
184 | namely whether or not to actually make GUI calls. Additionally those | |
185 | who wish to /DELAYLOAD:GDI32.DLL and /DELAYLOAD:USER32.DLL and | |
186 | actually keep them off service process should consider implementing | |
187 | and exporting from .exe image in question own _OPENSSL_isservice not | |
188 | relying on USER32.DLL. E.g., on Windows Vista and later you could: | |
189 | ||
190 | __declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void) | |
191 | { | |
192 | DWORD sess; | |
193 | ||
194 | if (ProcessIdToSessionId(GetCurrentProcessId(), &sess)) | |
195 | return sess == 0; | |
196 | return FALSE; | |
197 | } | |
198 | ||
199 | If you link with OpenSSL .DLLs, then you're expected to include into | |
200 | your application code a small "shim" snippet, which provides | |
201 | the glue between the OpenSSL BIO layer and your compiler run-time. | |
202 | See also the OPENSSL_Applink manual page. | |
203 | ||
204 | Hosted builds using Cygwin | |
205 | ========================== | |
206 | ||
207 | Cygwin implements a POSIX/Unix runtime system (cygwin1.dll) on top of the | |
208 | Windows subsystem and provides a Bash shell and GNU tools environment. | |
209 | Consequently, a build of OpenSSL with Cygwin is virtually identical to the | |
210 | Unix procedure. | |
211 | ||
212 | To build OpenSSL using Cygwin, you need to: | |
97a479c6 | 213 | |
474853c3 | 214 | * Install Cygwin, see <https://cygwin.com/> |
97a479c6 | 215 | |
df4c1d80 DDO |
216 | * Install Cygwin Perl, at least version 5.10.0 |
217 | and ensure it is in the $PATH | |
97a479c6 | 218 | |
df4c1d80 | 219 | * Run the Cygwin Bash shell |
97a479c6 | 220 | |
dc589dae | 221 | Apart from that, follow the Unix / Linux instructions in INSTALL.md. |
97a479c6 | 222 | |
dc589dae DMSP |
223 | NOTE: "make test" and normal file operations may fail in directories |
224 | mounted as text (i.e. mount -t c:\somewhere /home) due to Cygwin | |
225 | stripping of carriage returns. To avoid this ensure that a binary | |
226 | mount is used, e.g. mount -b c:\somewhere /home. |