OpenSSL | Static Linking

OpenSSL can be linked directly inside your application executable, instead of being loaded at runtime from the libcrypto and libssl DLL files. This means an application that uses TLS does not need to deploy any OpenSSL DLL, everything it needs is already inside the .exe.

This is useful when you want to distribute a single file, when you cannot guarantee that the target machine has the right OpenSSL DLL installed, or when your deployment process does not allow extra files next to the executable.

Requirements

How to Configure

There is nothing to set up. Just add the unit sgcIdSSLOpenSSL_Static to the uses clause of your project, for example in the main .dpr file:

uses

  sgcIdSSLOpenSSL_Static;

That is all. There is no compiler directive to enable and no OpenSSL API version to choose, your application starts using the OpenSSL library linked into the executable the next time it runs, for both client and server components. If you remove the unit from the uses clause, your application goes back to loading the OpenSSL DLLs exactly as before.

The OpenSSL version currently linked is 3.5.7. This version is updated from time to time to include the latest OpenSSL fixes, so you don't need to track or deploy OpenSSL versions yourself.

Common Errors

E2045 Bad object file format

This means you are compiling with a Delphi version older than XE2. Static linking requires Delphi XE2 or newer, remove the sgcIdSSLOpenSSL_Static unit from the uses clause and your application will keep working with the OpenSSL DLLs.