Skip to content

Commit

Permalink
m4: Fix linking with OpenSSL 1.1.0+ and 3+ on Windows.
Browse files Browse the repository at this point in the history
OpenSSL 1.1.0 changed the library names from libeay32 and ssleay32 to
standard libssl and libcrypto.  All the versions of OpenSSL that used
old names reached their official EoL, so it should be safe to just
migrate to new names.  They can still be supported via premium support
option, but I don't think that is important for us.

Also, OpenSSL installers for older versions had the following folder
structure:

  C:\OPENSSL-WIN64\
  +---bin
  +---include
  |   +---openssl
  +---lib
      |   libeay32.lib
      |   ssleay32.lib
      +---VC
              libeay32MD.lib
              libeay32MDd.lib
              libeay32MT.lib
              libeay32MTd.lib
              ssleay32MD.lib
              ssleay32MDd.lib
              ssleay32MT.lib
              ssleay32MTd.lib

With newer OpenSSL 3+ the structure is different:

  C:\OPENSSL-WIN64
  +---bin
  +---include
  |   +---openssl
  +---lib
      +---VC
          +---x64
              +---MD
              |       libcrypto.lib
              |       libssl.lib
              +---MDd
              |       libcrypto.lib
              |       libssl.lib
              +---MT
              |       libcrypto.lib
              |       libssl.lib
              +---MTd
                      libcrypto.lib
                      libssl.lib

Basically, instead of one generic library in the lib folder and a bunch
of differently named versions of it for different type of linkage, we
now have multiple instances of the library located in different folders
based on the linkage type.  So, we have to provide an exact path in
order to find the library.

'lib/VC/x64/MT' was chosen in this patch since it is a way used for
building in build-aux/ccl.
MD stands for dynamic linking, MT is static, 'd' stands for debug
versions of the libraries.

While at it, fixing documentation examples to point to Win64 default
installation folder.

Acked-by: Simon Horman <[email protected]>
Acked-by: Alin-Gabriel Serdean <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Mar 4, 2024
1 parent f5fa9a0 commit 68e9312
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Documentation/intro/install/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ The following explains the steps in some detail.
`OpenSSL for Windows <https://wiki.openssl.org/index.php/Binaries>`__

Note down the directory where OpenSSL is installed (e.g.:
``C:/OpenSSL-Win32``) for later use.
``C:/OpenSSL-Win64``) for later use.

.. note::

Expand Down Expand Up @@ -182,7 +182,7 @@ To configure with SSL support, add the requisite additional options:
--localstatedir="C:/openvswitch/var"
--sysconfdir="C:/openvswitch/etc" \
--with-pthread="C:/pthread" \
--enable-ssl --with-openssl="C:/OpenSSL-Win32"
--enable-ssl --with-openssl="C:/OpenSSL-Win64"

Finally, to the kernel module also:

Expand All @@ -194,7 +194,7 @@ Finally, to the kernel module also:
--localstatedir="C:/openvswitch/var" \
--sysconfdir="C:/openvswitch/etc" \
--with-pthread="C:/pthread" \
--enable-ssl --with-openssl="C:/OpenSSL-Win32" \
--enable-ssl --with-openssl="C:/OpenSSL-Win64" \
--with-vstudiotarget="<target type>" \
--with-vstudiotargetver="<target versions>"

Expand Down
3 changes: 2 additions & 1 deletion m4/ax_check_openssl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ AC_DEFUN([AX_CHECK_OPENSSL], [
SSL_INCLUDES="-I$ssldir/include"
SSL_LDFLAGS="-L$ssldir/lib"
if test "$WIN32" = "yes"; then
SSL_LIBS="-lssleay32 -llibeay32"
SSL_LDFLAGS="$SSL_LDFLAGS -L$ssldir/lib/VC/x64/MT"
SSL_LIBS="-llibssl -llibcrypto"
SSL_DIR=/$(echo ${ssldir} | ${SED} -e 's/://')
else
SSL_LIBS="-lssl -lcrypto"
Expand Down

0 comments on commit 68e9312

Please sign in to comment.