2021-02-02 01:53:29 +08:00
|
|
|
Notes for Windows platforms
|
2020-09-07 23:38:48 +08:00
|
|
|
===========================
|
2003-04-11 03:11:32 +08:00
|
|
|
|
2023-11-14 18:34:43 +08:00
|
|
|
- [Native builds using Visual C++](#native-builds-using-visual-c)
|
2020-11-28 10:21:03 +08:00
|
|
|
- [Native builds using Embarcadero C++Builder](
|
2023-11-14 18:34:43 +08:00
|
|
|
#native-builds-using-embarcadero-cbuilder)
|
2021-02-02 01:53:29 +08:00
|
|
|
- [Native builds using MinGW](#native-builds-using-mingw)
|
|
|
|
- [Linking native applications](#linking-native-applications)
|
|
|
|
- [Hosted builds using Cygwin](#hosted-builds-using-cygwin)
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
There are various options to build and run OpenSSL on the Windows platforms.
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
"Native" OpenSSL uses the Windows APIs directly at run time.
|
|
|
|
To build a native OpenSSL you can either use:
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Microsoft Visual C++ (MSVC) C compiler on the command line
|
2020-11-28 10:21:03 +08:00
|
|
|
or
|
|
|
|
Embarcadero C++Builder
|
2021-02-02 01:53:29 +08:00
|
|
|
or
|
|
|
|
MinGW cross compiler
|
|
|
|
run on the GNU-like development environment MSYS2
|
|
|
|
or run on Linux or Cygwin
|
2018-03-16 22:39:51 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
"Hosted" OpenSSL relies on an external POSIX compatibility layer
|
|
|
|
for building (using GNU/Unix shell, compiler, and tools) and at run time.
|
2022-09-22 19:27:27 +08:00
|
|
|
For this option, you can use Cygwin.
|
2003-04-11 03:11:32 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Native builds using Visual C++
|
|
|
|
==============================
|
2016-05-23 21:11:04 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
The native builds using Visual C++ have a `VC-*` prefix.
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Requirement details
|
|
|
|
-------------------
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
In addition to the requirements and instructions listed in `INSTALL.md`,
|
2021-02-02 01:53:29 +08:00
|
|
|
these are required as well:
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
### Perl
|
|
|
|
|
|
|
|
We recommend Strawberry Perl, available from <http://strawberryperl.com/>
|
|
|
|
Please read NOTES.PERL for more information, including the use of CPAN.
|
|
|
|
An alternative is ActiveState Perl, <https://www.activestate.com/ActivePerl>
|
|
|
|
for which you may need to explicitly build the Perl module Win32/Console.pm
|
|
|
|
via <https://platform.activestate.com/ActiveState> and then download it.
|
|
|
|
|
|
|
|
### Microsoft Visual C compiler.
|
|
|
|
|
|
|
|
Since these are proprietary and ever-changing we cannot test them all.
|
|
|
|
Older versions may not work. Use a recent version wherever possible.
|
|
|
|
|
|
|
|
### Netwide Assembler (NASM)
|
|
|
|
|
|
|
|
NASM is the only supported assembler. It is available from <https://www.nasm.us>.
|
|
|
|
|
|
|
|
Quick start
|
|
|
|
-----------
|
2020-06-09 20:04:49 +08:00
|
|
|
|
|
|
|
1. Install Perl
|
|
|
|
|
|
|
|
2. Install NASM
|
|
|
|
|
|
|
|
3. Make sure both Perl and NASM are on your %PATH%
|
|
|
|
|
|
|
|
4. Use Visual Studio Developer Command Prompt with administrative privileges,
|
|
|
|
choosing one of its variants depending on the intended architecture.
|
2022-03-24 23:18:33 +08:00
|
|
|
Or run `cmd` and execute `vcvarsall.bat` with one of the options `x86`,
|
|
|
|
`x86_amd64`, `x86_arm`, `x86_arm64`, `amd64`, `amd64_x86`, `amd64_arm`,
|
|
|
|
or `amd64_arm64`.
|
|
|
|
This sets up the environment variables needed for `nmake.exe`, `cl.exe`,
|
|
|
|
etc.
|
2020-09-07 23:38:48 +08:00
|
|
|
See also
|
|
|
|
<https://docs.microsoft.com/cpp/build/building-on-the-command-line>
|
2020-06-09 20:04:49 +08:00
|
|
|
|
|
|
|
5. From the root of the OpenSSL source directory enter
|
2022-03-24 23:18:33 +08:00
|
|
|
- `perl Configure VC-WIN32` if you want 32-bit OpenSSL or
|
|
|
|
- `perl Configure VC-WIN64A` if you want 64-bit OpenSSL or
|
|
|
|
- `perl Configure VC-WIN64-ARM` if you want Windows on Arm (win-arm64)
|
|
|
|
OpenSSL or
|
2023-03-16 21:27:12 +08:00
|
|
|
- `perl Configure VC-WIN64-CLANGASM-ARM` if you want Windows on Arm (win-arm64)
|
|
|
|
OpenSSL with assembly support using clang-cl as assembler or
|
|
|
|
- `perl Configure VC-CLANG-WIN64-CLANGASM-ARM` if you want Windows on Arm (win-arm64)
|
|
|
|
OpenSSL using clang-cl as both compiler and assembler or
|
2023-03-02 18:51:40 +08:00
|
|
|
- `perl Configure VC-WIN32-HYBRIDCRT` if you want 32-bit OpenSSL dependent
|
|
|
|
on the Universal CRT or
|
|
|
|
- `perl Configure VC-WIN64A-HYBRIDCRT` if you want 64-bit OpenSSL dependent
|
|
|
|
on the Universal CRT or
|
2022-03-24 23:18:33 +08:00
|
|
|
- `perl Configure` to let Configure figure out the platform
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
6. `nmake`
|
2006-10-23 15:38:30 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
7. `nmake test`
|
2003-04-11 03:11:32 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
8. `nmake install`
|
2003-04-11 03:11:32 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
For the full installation instructions, or if anything goes wrong at any stage,
|
|
|
|
check the INSTALL.md file.
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Installation directories
|
|
|
|
------------------------
|
2016-03-17 17:08:25 +08:00
|
|
|
|
2024-06-26 23:50:46 +08:00
|
|
|
On most Unix platforms installation directories are determined at build time via
|
2024-06-25 22:57:52 +08:00
|
|
|
constant defines. On Windows platforms however, installation directories are
|
|
|
|
determined via registry keys, as it is common practice to build OpenSSL and
|
|
|
|
install it to a variety of locations.
|
2016-03-17 17:08:25 +08:00
|
|
|
|
2024-06-25 22:57:52 +08:00
|
|
|
The following keys:
|
2024-06-07 02:37:37 +08:00
|
|
|
|
2024-06-08 01:36:46 +08:00
|
|
|
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL-<version>-<ctx>\OPENSSLDIR`
|
|
|
|
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL-<version>-<ctx>\ENGINESDIR`
|
|
|
|
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\OpenSSL-<version>-<ctx>\MODULESDIR`
|
2024-06-07 02:37:37 +08:00
|
|
|
|
|
|
|
Can be administratively set, and openssl will take the paths found there as the
|
2024-06-08 01:36:46 +08:00
|
|
|
values for OPENSSLDIR, ENGINESDIR and MODULESDIR respectively.
|
2024-06-07 02:37:37 +08:00
|
|
|
|
|
|
|
To enable the reading of registry keys from windows builds, add
|
2024-06-08 01:36:46 +08:00
|
|
|
`-DOPENSSL_WINCTX=<string>`to the Configure command line. This define is used
|
2024-06-21 23:05:22 +08:00
|
|
|
at build-time to construct library build specific registry key paths of the
|
2024-06-08 01:36:46 +08:00
|
|
|
format:
|
|
|
|
`\\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\OpenSSL-<version>-<ctx>`
|
2024-06-25 22:57:52 +08:00
|
|
|
|
2024-06-26 23:50:46 +08:00
|
|
|
Where `<version>` is the major.minor version of the library being
|
2024-06-08 01:36:46 +08:00
|
|
|
built, and `<ctx>` is the value specified by `-DOPENSSL_WINCTX`. This allows
|
|
|
|
for multiple openssl builds to be created and installed on a single system, in
|
|
|
|
which each library can use its own set of registry keys.
|
2024-06-07 02:37:37 +08:00
|
|
|
|
|
|
|
Note the installer available at <https://github.com/openssl/installer> will set
|
|
|
|
these keys when the installer is run.
|
|
|
|
|
2024-06-26 23:50:46 +08:00
|
|
|
A summary table of behavior on Windows platforms
|
|
|
|
|
|
|
|
|`OSSL_WINCTX`|Registry key|OpenSSL Behavior |
|
|
|
|
|-------------|------------|------------------------------------------|
|
|
|
|
|Defined | Defined |OpenSSL Reads Paths from Registry |
|
2024-06-26 23:52:22 +08:00
|
|
|
|Defined | Undefined |OpenSSL returns errors on module/conf load|
|
2024-06-26 23:50:46 +08:00
|
|
|
|Undefined | N/A |OpenSSL uses build time defaults |
|
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
Special notes for Universal Windows Platform builds, aka `VC-*-UWP`
|
|
|
|
-------------------------------------------------------------------
|
2019-05-12 05:10:58 +08:00
|
|
|
|
|
|
|
- UWP targets only support building the static and dynamic libraries.
|
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
- You should define the platform type to `uwp` and the target arch via
|
|
|
|
`vcvarsall.bat` before you compile. For example, if you want to build
|
|
|
|
`arm64` builds, you should run `vcvarsall.bat x86_arm64 uwp`.
|
2019-05-12 05:10:58 +08:00
|
|
|
|
2020-11-28 10:21:03 +08:00
|
|
|
Native builds using Embarcadero C++Builder
|
|
|
|
=========================================
|
|
|
|
|
|
|
|
This toolchain (a descendant of Turbo/Borland C++) is an alternative to MSVC.
|
2020-12-07 07:04:45 +08:00
|
|
|
OpenSSL currently includes an experimental 32-bit configuration targeting the
|
2022-03-24 23:18:33 +08:00
|
|
|
Clang-based compiler (`bcc32c.exe`) in v10.3.3 Community Edition.
|
2020-11-28 10:21:03 +08:00
|
|
|
<https://www.embarcadero.com/products/cbuilder/starter>
|
|
|
|
|
|
|
|
1. Install Perl.
|
|
|
|
|
|
|
|
2. Open the RAD Studio Command Prompt.
|
|
|
|
|
|
|
|
3. Go to the root of the OpenSSL source directory and run:
|
2022-03-24 23:18:33 +08:00
|
|
|
`perl Configure BC-32 --prefix=%CD%`
|
2020-11-28 10:21:03 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
4. `make -N`
|
2020-11-28 10:21:03 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
5. `make -N test`
|
2020-12-07 07:04:45 +08:00
|
|
|
|
|
|
|
6. Build your program against this OpenSSL:
|
2020-11-28 10:21:03 +08:00
|
|
|
* Set your include search path to the "include" subdirectory of OpenSSL.
|
|
|
|
* Set your library search path to the OpenSSL source directory.
|
|
|
|
|
2020-12-07 07:04:45 +08:00
|
|
|
Note that this is very experimental. Support for 64-bit and other Configure
|
|
|
|
options is still pending.
|
2020-11-28 10:21:03 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Native builds using MinGW
|
|
|
|
=========================
|
2016-03-18 06:15:12 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
MinGW offers an alternative way to build native OpenSSL, by cross compilation.
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
* Usually the build is done on Windows in a GNU-like environment called MSYS2.
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
MSYS2 provides GNU tools, a Unix-like command prompt,
|
|
|
|
and a UNIX compatibility layer for applications.
|
2020-06-30 03:13:07 +08:00
|
|
|
However, in this context it is only used for building OpenSSL.
|
2020-06-09 20:04:49 +08:00
|
|
|
The resulting OpenSSL does not rely on MSYS2 to run and is fully native.
|
|
|
|
|
|
|
|
Requirement details
|
|
|
|
|
2020-09-07 23:38:48 +08:00
|
|
|
- MSYS2 shell, from <https://www.msys2.org/>
|
2020-06-09 20:04:49 +08:00
|
|
|
|
|
|
|
- Perl, at least version 5.10.0, which usually comes pre-installed with MSYS2
|
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
- make, installed using `pacman -S make` into the MSYS2 environment
|
2020-06-09 20:04:49 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
- MinGW[64] compiler: `mingw-w64-i686-gcc` and/or `mingw-w64-x86_64-gcc`.
|
2020-06-09 20:04:49 +08:00
|
|
|
These compilers must be on your MSYS2 $PATH.
|
|
|
|
A common error is to not have these on your $PATH.
|
|
|
|
The MSYS2 version of gcc will not work correctly here.
|
|
|
|
|
|
|
|
In the MSYS2 shell do the configuration depending on the target architecture:
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
./Configure mingw ...
|
2022-03-24 23:18:33 +08:00
|
|
|
|
2018-03-16 22:39:51 +08:00
|
|
|
or
|
2022-03-24 23:18:33 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
./Configure mingw64 ...
|
2022-03-24 23:18:33 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
or
|
2022-03-24 23:18:33 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
./Configure ...
|
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
for the default architecture.
|
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
Apart from that, follow the Unix / Linux instructions in `INSTALL.md`.
|
2020-06-09 20:04:49 +08:00
|
|
|
|
|
|
|
* It is also possible to build mingw[64] on Linux or Cygwin.
|
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
In this case configure with the corresponding `--cross-compile-prefix=`
|
|
|
|
option. For example
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
./Configure mingw --cross-compile-prefix=i686-w64-mingw32- ...
|
2022-03-24 23:18:33 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
or
|
2022-03-24 23:18:33 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
./Configure mingw64 --cross-compile-prefix=x86_64-w64-mingw32- ...
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
This requires that you've installed the necessary add-on packages for
|
|
|
|
mingw[64] cross compilation.
|
2016-03-08 21:44:46 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Linking native applications
|
|
|
|
===========================
|
|
|
|
|
|
|
|
This section applies to all native builds.
|
|
|
|
|
2022-09-22 19:27:27 +08:00
|
|
|
If you link with static OpenSSL libraries, then you're expected to
|
2022-03-24 23:18:33 +08:00
|
|
|
additionally link your application with `WS2_32.LIB`, `GDI32.LIB`,
|
|
|
|
`ADVAPI32.LIB`, `CRYPT32.LIB` and `USER32.LIB`. Those developing
|
2021-02-02 01:53:29 +08:00
|
|
|
non-interactive service applications might feel concerned about
|
2022-03-24 23:18:33 +08:00
|
|
|
linking with `GDI32.LIB` and `USER32.LIB`, as they are justly associated
|
2021-02-02 01:53:29 +08:00
|
|
|
with interactive desktop, which is not available to service
|
|
|
|
processes. The toolkit is designed to detect in which context it's
|
|
|
|
currently executed, GUI, console app or service, and act accordingly,
|
2022-09-22 19:27:27 +08:00
|
|
|
namely whether to actually make GUI calls. Additionally, those
|
2022-03-24 23:18:33 +08:00
|
|
|
who wish to `/DELAYLOAD:GDI32.DLL` and `/DELAYLOAD:USER32.DLL` and
|
2021-02-02 01:53:29 +08:00
|
|
|
actually keep them off service process should consider implementing
|
2022-03-24 23:18:33 +08:00
|
|
|
and exporting from .exe image in question own `_OPENSSL_isservice` not
|
|
|
|
relying on `USER32.DLL`. E.g., on Windows Vista and later you could:
|
2021-02-02 01:53:29 +08:00
|
|
|
|
|
|
|
__declspec(dllexport) __cdecl BOOL _OPENSSL_isservice(void)
|
|
|
|
{
|
|
|
|
DWORD sess;
|
|
|
|
|
|
|
|
if (ProcessIdToSessionId(GetCurrentProcessId(), &sess))
|
|
|
|
return sess == 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
If you link with OpenSSL .DLLs, then you're expected to include into
|
|
|
|
your application code a small "shim" snippet, which provides
|
|
|
|
the glue between the OpenSSL BIO layer and your compiler run-time.
|
|
|
|
See also the OPENSSL_Applink manual page.
|
|
|
|
|
|
|
|
Hosted builds using Cygwin
|
|
|
|
==========================
|
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
Cygwin implements a POSIX/Unix runtime system (`cygwin1.dll`) on top of the
|
2021-02-02 01:53:29 +08:00
|
|
|
Windows subsystem and provides a Bash shell and GNU tools environment.
|
|
|
|
Consequently, a build of OpenSSL with Cygwin is virtually identical to the
|
|
|
|
Unix procedure.
|
|
|
|
|
|
|
|
To build OpenSSL using Cygwin, you need to:
|
2018-03-16 22:39:51 +08:00
|
|
|
|
2020-09-07 23:38:48 +08:00
|
|
|
* Install Cygwin, see <https://cygwin.com/>
|
2018-03-16 22:39:51 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
* Install Cygwin Perl, at least version 5.10.0
|
|
|
|
and ensure it is in the $PATH
|
2018-03-16 22:39:51 +08:00
|
|
|
|
2020-06-09 20:04:49 +08:00
|
|
|
* Run the Cygwin Bash shell
|
2018-03-16 22:39:51 +08:00
|
|
|
|
2021-02-02 01:53:29 +08:00
|
|
|
Apart from that, follow the Unix / Linux instructions in INSTALL.md.
|
2018-03-16 22:39:51 +08:00
|
|
|
|
2022-03-24 23:18:33 +08:00
|
|
|
NOTE: `make test` and normal file operations may fail in directories
|
|
|
|
mounted as text (i.e. `mount -t c:\somewhere /home`) due to Cygwin
|
2022-09-22 19:27:27 +08:00
|
|
|
stripping of carriage returns. To avoid this, ensure that a binary
|
2022-03-24 23:18:33 +08:00
|
|
|
mount is used, e.g. `mount -b c:\somewhere /home`.
|