Skip to content

libssh2 1.11.0 cannot link with openssl 1.1.1 #1075

Closed

Description

@icebluey

Libssh2 1.11.0 donot link with openssl 1.1.1, but libssh2 1.10.0 do.

OS: RHEL 7
Openssl Version: OpenSSL 1.1.1t

I installed openssl 1.1.1 to /usr/local/openssl-1.1.1, and built libssh2 1.11.0 with following steps:

./configure --build=x86_64-linux-gnu --host=x86_64-linux-gnu \
--prefix=/usr --libdir=/usr/lib64 --includedir=/usr/include --sysconfdir=/etc \
--enable-shared --enable-static --disable-silent-rules --with-libz --enable-debug \
--with-crypto=openssl --with-libssl-prefix=/usr/local/openssl-1.1.1 \
&& make

The output:

checking for shared library run path origin... done
checking for libssl... yes
checking how to link with libssl... /usr/local/openssl-1.1.1/lib/libssl.so /usr/local/openssl-1.1.1/lib/libcrypto.so -Wl,-rpath -Wl,/usr/local/openssl-1.1.1/lib
checking for libz... yes
checking how to link with libz... /usr/lib64/libz.so
checking whether to enable pedantic and debug compiler options... checking how to run the C preprocessor... gcc -E
checking if cpp -P is needed... yes
checking if cpp -P works... yes
yes
checking if compiler is clang... no
checking for icc in use... no
checking gcc version... 11
configure: Added this set of compiler options: -W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wundef -Wno-long-long -Wno-multichar -Wshadow -Wsign-compare -Wunused -Wfloat-equal -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wno-system-headers -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -ftree-vrp -Wdouble-promotion -Wformat=2 -Warray-bounds=2 -Wshift-negative-value -Wshift-overflow=2 -Wnull-dereference -fdelete-null-pointer-checks -Wduplicated-cond -Wunused-const-variable -Wduplicated-branches -Wrestrict -Walloc-zero -Wformat-overflow=2 -Wformat-truncation=1 -Warith-conversion -Wenum-conversion -isystem /usr/local/openssl-1.1.1/include
checking whether to enable hidden symbols in the library... no
...
configure: summary of build options:

  version:          1.11.0
  Host type:        x86_64-pc-linux-gnu
  Install prefix:   /usr
  Compiler:         gcc
  Compiler flags:    -g -g -W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wundef -Wno-long-long -Wno-multichar -Wshadow -Wsign-compare -Wunused -Wfloat-equal -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wno-system-headers -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -ftree-vrp -Wdouble-promotion -Wformat=2 -Warray-bounds=2 -Wshift-negative-value -Wshift-overflow=2 -Wnull-dereference -fdelete-null-pointer-checks -Wduplicated-cond -Wunused-const-variable -Wduplicated-branches -Wrestrict -Walloc-zero -Wformat-overflow=2 -Wformat-truncation=1 -Warith-conversion -Wenum-conversion -isystem /usr/local/openssl-1.1.1/include
  Library types:    Shared=yes, Static=yes
  Crypto library:   OpenSSL
  zlib compression: yes
  Clear memory:     yes
  Debug build:      yes
  Build examples:   yes
  Run Docker tests: yes
  Run sshd tests:   yes
  Path to sshd:     /usr/sbin/sshd (only for self-tests)

...

/bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -g -W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wundef -Wno-long-long -Wno-multichar -Wshadow -Wsign-compare -Wunused -Wfloat-equal -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wno-system-headers -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -ftree-vrp -Wdouble-promotion -Wformat=2 -Warray-bounds=2 -Wshift-negative-value -Wshift-overflow=2 -Wnull-dereference -fdelete-null-pointer-checks -Wduplicated-cond -Wunused-const-variable -Wduplicated-branches -Wrestrict -Walloc-zero -Wformat-overflow=2 -Wformat-truncation=1 -Warith-conversion -Wenum-conversion -isystem /usr/local/openssl-1.1.1/include   -o x11 x11.o ../src/libssh2.la -L/usr/local/openssl-1.1.1/lib -lssl -L/usr/local/openssl-1.1.1/lib -lcrypto -R/usr/local/openssl-1.1.1/lib
libtool: link: gcc -g -g -W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wundef -Wno-long-long -Wno-multichar -Wshadow -Wsign-compare -Wunused -Wfloat-equal -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wno-system-headers -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -ftree-vrp -Wdouble-promotion -Wformat=2 -Warray-bounds=2 -Wshift-negative-value -Wshift-overflow=2 -Wnull-dereference -fdelete-null-pointer-checks -Wduplicated-cond -Wunused-const-variable -Wduplicated-branches -Wrestrict -Walloc-zero -Wformat-overflow=2 -Wformat-truncation=1 -Warith-conversion -Wenum-conversion -isystem /usr/local/openssl-1.1.1/include -o .libs/x11 x11.o  ../src/.libs/libssh2.so -L/usr/local/openssl-1.1.1/lib -lssl -lcrypto -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/usr/local/openssl-1.1.1/lib
/usr/bin/ld: warning: libssl.so.10, needed by ../src/.libs/libssh2.so, may conflict with libssl.so.1.1
/usr/bin/ld: warning: libcrypto.so.10, needed by ../src/.libs/libssh2.so, may conflict with libcrypto.so.1.1

Full output

# readelf -d src/.libs/libssh2.so.1.0.1 

Dynamic section at offset 0x59d88 contains 29 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libssl.so.10]
 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.10]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [libssh2.so.1]
 0x000000000000001d (RUNPATH)            Library runpath: [/usr/local/openssl-1.1.1/lib]
 

Activity

  1. vszakats commented on May 31, 2023

    @vszakats
    Member

    The breaking commit is possibly 4f0f4bf #941, which changed the position of the crypto lib (with a subsequent unrelated fix for lib order in d4f58f0 from d93ccf4 #1013).

    I'm not grasping why this fallout happens, nor can I reproduce it or propose a fix, but hopefully this may help developing one.

  2. vszakats commented on May 31, 2023

    @vszakats
    Member

    Shot in the dark patch:

    diff --git a/configure.ac b/configure.ac
    index c0ad339d..15e33195 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -389,6 +389,8 @@ elif test "$found_crypto" = "mbedtls"; then
       LIBS="${LIBS} ${LTLIBMBEDCRYPTO}"
     fi
     
    +LIBS="${LIBS} ${LTLIBZ}"
    +
     AC_CONFIG_FILES([Makefile
                      src/Makefile
                      tests/Makefile
    diff --git a/src/Makefile.am b/src/Makefile.am
    index 91222d54..380674bc 100644
    --- a/src/Makefile.am
    +++ b/src/Makefile.am
    @@ -48,8 +48,7 @@ VERSION=-version-info 1:1:0
     #
     
     libssh2_la_LDFLAGS = $(VERSION) -no-undefined \
    -  -export-symbols-regex '^libssh2_.*' \
    -  $(LTLIBZ)
    +  -export-symbols-regex '^libssh2_.*'
     
     if HAVE_WINDRES
     .rc.lo:
  3. icebluey commented on Jun 1, 2023

    @icebluey
    Author

    Shot in the dark patch:

    diff --git a/configure.ac b/configure.ac
    index c0ad339d..15e33195 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -389,6 +389,8 @@ elif test "$found_crypto" = "mbedtls"; then
       LIBS="${LIBS} ${LTLIBMBEDCRYPTO}"
     fi
     
    +LIBS="${LIBS} ${LTLIBZ}"
    +
     AC_CONFIG_FILES([Makefile
                      src/Makefile
                      tests/Makefile
    diff --git a/src/Makefile.am b/src/Makefile.am
    index 91222d54..380674bc 100644
    --- a/src/Makefile.am
    +++ b/src/Makefile.am
    @@ -48,8 +48,7 @@ VERSION=-version-info 1:1:0
     #
     
     libssh2_la_LDFLAGS = $(VERSION) -no-undefined \
    -  -export-symbols-regex '^libssh2_.*' \
    -  $(LTLIBZ)
    +  -export-symbols-regex '^libssh2_.*'
     
     if HAVE_WINDRES
     .rc.lo:
    # readelf -d src/.libs/libssh2.so.1.0.1 
    
    Dynamic section at offset 0x59d88 contains 29 entries:
      Tag        Type                         Name/Value
     0x0000000000000001 (NEEDED)             Shared library: [libssl.so.1.1]
     0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.1]
     0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
     0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
     0x000000000000000e (SONAME)             Library soname: [libssh2.so.1]
     0x000000000000001d (RUNPATH)            Library runpath: [/usr/local/openssl-1.1.1/lib]
    

    This patch works.
    Maybe for libssh2 1.11.1 ?

  4. vszakats commented on Jun 1, 2023

    @vszakats
    Member

    Thanks for your tests! I'll make it a PR.

  5. added 2 commits that reference this issue on Jun 1, 2023
    7e33f3b
    4db71b0
  6. added a commit that references this issue on Jun 1, 2023
    c89174a
  7. added a commit that references this issue on Jul 16, 2023
    3258f72
  8. added a commit that references this issue on Jul 14, 2024
    ea63d76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions