diff mbox series

[ovs-dev,v2,3/4] m4: Fix linking with OpenSSL 1.1.0+ and 3+ on Windows.

Message ID 20240301211045.3714106-4-i.maximets@ovn.org
State Accepted
Commit 68e93122144d61d531849956a3037288a575e761
Delegated to: Ilya Maximets
Headers show
Series Windows: Fix OpenSSL build and ovs-pki. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ilya Maximets March 1, 2024, 9:10 p.m. UTC
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.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 Documentation/intro/install/windows.rst | 6 +++---
 m4/ax_check_openssl.m4                  | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Simon Horman March 4, 2024, 3:28 p.m. UTC | #1
On Fri, Mar 01, 2024 at 10:10:39PM +0100, Ilya Maximets wrote:
> 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.
> 
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Acked-by: Simon Horman <horms@ovn.org>
diff mbox series

Patch

diff --git a/Documentation/intro/install/windows.rst b/Documentation/intro/install/windows.rst
index fce099d5d..efdb8aebc 100644
--- a/Documentation/intro/install/windows.rst
+++ b/Documentation/intro/install/windows.rst
@@ -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::
 
@@ -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:
 
@@ -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>"
 
diff --git a/m4/ax_check_openssl.m4 b/m4/ax_check_openssl.m4
index 281d4dc65..faa5babde 100644
--- a/m4/ax_check_openssl.m4
+++ b/m4/ax_check_openssl.m4
@@ -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"