• Linking with specific version of shared library

    From vadim.dvorkin@gmail.com@21:1/5 to All on Mon Nov 12 23:38:55 2018
    Hello all,

    Can somebody suggest parameters for gcc to link my exe with libcrypto of specific version - libcrypto.so.1.0.0? I need exactly this, because I am using libssl also, and libssl linked with libcrypto.so.1.0.0.

    I am working on AIX 7.1. This is regular for AIX, that the shared libraries are provided as archive of few shared libraries:

    bash-4.3$ ar -tv /usr/lib/libssl.a
    rwxrwxr-x 435159/781431 646757 Oct 26 01:23 2014 libssl.so
    rwxrwxr-x 435159/781431 510331 Oct 26 01:24 2014 libssl.so.0.9.8
    rwxrwxr-x 435159/781431 646757 Oct 26 01:21 2014 libssl.so.1.0.0

    bash-4.3# ar-tv -- /usr/lib/libcrypto.a
    rwxrwxr-x 435159/781431 2965597 Oct 26 01:22 2014 libcrypto.so
    rwxrwxr-x 435159/781431 2253850 Oct 26 01:25 2014 libcrypto.so.0.9.8
    rwxrwxr-x 435159/781431 2965597 Oct 26 01:21 2014 libcrypto.so.1.0.0


    If I will use "gcc ... -lssl -lcrypt" the ldd output will be like
    libmylib.so needs:
    /usr/lib/libdl.a(shr.o)
    /usr/lib/libssl.a(libssl.so)
    /usr/lib/libcrypto.a(libcrypto.so.1.0.0)
    /unix
    /usr/lib/libcrypto.a(libcrypto.so)

    Thanks in advance,
    Vadim

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lorinczy Zsigmond@21:1/5 to vadim.dvorkin@gmail.com on Tue Nov 13 11:18:01 2018
    Hi, my idea would be using standalone '*.so.1.0.0' files instead of
    archive members:

    gcc -o libmylib.so ... \
    /usr/lib/libssl.so.1.0.0 /usr/lib/libcrypto.so.1.0.0

    To achieve this you have to extract the members from the archives
    and re-link libssl.so like this:

    -------------------------------------------------BEGIN---
    #!/bin/sh

    set -e

    ar -X32 -xv /usr/lib/libcrypto.a libcrypto.so.1.0.0
    ar -X32 -xv /usr/lib/libssl.a libssl.so.1.0.0

    explist_so libcrypto.so.1.0.0 >libcrypto.exp
    explist_so libssl.so.1.0.0 >libssl.exp

    mv libssl.so.1.0.0 libssl.bak.1.0.0

    ld -b32 -r -o libssl.o.1.0.0 -bnso libssl.bak.1.0.0
    ld -b32 -G -bnoentry -bernotok -bE:libssl.exp -o libssl.so.1.0.0 \
    libssl.o.1.0.0 libcrypto.so.1.0.0 -lpthreads -lc

    ln -sf libssl.so.1.0.0 libssl.so
    ln -sf libcrypto.so.1.0.0 libcrypto.so -------------------------------------------------END-----

    'explist_so' script:http://lzsiga.users.sourceforge.net/explist_so
    more details: http://lzsiga.users.sourceforge.net/aix-linking.html


    On 2018-11-13 08:38, vadim.dvorkin@gmail.com wrote:
    Hello all,

    Can somebody suggest parameters for gcc to link my exe with libcrypto of specific version - libcrypto.so.1.0.0? I need exactly this, because I am using libssl also, and libssl linked with libcrypto.so.1.0.0.

    I am working on AIX 7.1. This is regular for AIX, that the shared libraries are provided as archive of few shared libraries:

    bash-4.3$ ar -tv /usr/lib/libssl.a
    rwxrwxr-x 435159/781431 646757 Oct 26 01:23 2014 libssl.so
    rwxrwxr-x 435159/781431 510331 Oct 26 01:24 2014 libssl.so.0.9.8
    rwxrwxr-x 435159/781431 646757 Oct 26 01:21 2014 libssl.so.1.0.0

    bash-4.3# ar-tv -- /usr/lib/libcrypto.a
    rwxrwxr-x 435159/781431 2965597 Oct 26 01:22 2014 libcrypto.so
    rwxrwxr-x 435159/781431 2253850 Oct 26 01:25 2014 libcrypto.so.0.9.8 rwxrwxr-x 435159/781431 2965597 Oct 26 01:21 2014 libcrypto.so.1.0.0


    If I will use "gcc ... -lssl -lcrypt" the ldd output will be like
    libmylib.so needs:
    /usr/lib/libdl.a(shr.o)
    /usr/lib/libssl.a(libssl.so)
    /usr/lib/libcrypto.a(libcrypto.so.1.0.0)
    /unix
    /usr/lib/libcrypto.a(libcrypto.so)

    Thanks in advance,
    Vadim


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From vadim.dvorkin@gmail.com@21:1/5 to Lorinczy Zsigmond on Sat Nov 17 23:13:07 2018
    Thanks a lot for your quick and essential answer. Sorry my for delay.

    On Tuesday, November 13, 2018 at 12:18:10 PM UTC+2, Lorinczy Zsigmond wrote:
    Hi, my idea would be using standalone '*.so.1.0.0' files instead of
    archive members:

    gcc -o libmylib.so ... \
    /usr/lib/libssl.so.1.0.0 /usr/lib/libcrypto.so.1.0.0

    To achieve this you have to extract the members from the archives
    and re-link libssl.so like this:

    -------------------------------------------------BEGIN---
    #!/bin/sh

    set -e

    ar -X32 -xv /usr/lib/libcrypto.a libcrypto.so.1.0.0
    ar -X32 -xv /usr/lib/libssl.a libssl.so.1.0.0

    explist_so libcrypto.so.1.0.0 >libcrypto.exp
    explist_so libssl.so.1.0.0 >libssl.exp

    mv libssl.so.1.0.0 libssl.bak.1.0.0

    ld -b32 -r -o libssl.o.1.0.0 -bnso libssl.bak.1.0.0
    ld -b32 -G -bnoentry -bernotok -bE:libssl.exp -o libssl.so.1.0.0 \
    libssl.o.1.0.0 libcrypto.so.1.0.0 -lpthreads -lc

    ln -sf libssl.so.1.0.0 libssl.so
    ln -sf libcrypto.so.1.0.0 libcrypto.so -------------------------------------------------END-----

    'explist_so' script:http://lzsiga.users.sourceforge.net/explist_so
    more details: http://lzsiga.users.sourceforge.net/aix-linking.html



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)