Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linking with specific version of shared library

106 views
Skip to first unread message

vadim....@gmail.com

unread,
Nov 13, 2018, 2:38:59 AM11/13/18
to
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

Lorinczy Zsigmond

unread,
Nov 13, 2018, 5:18:10 AM11/13/18
to
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

vadim....@gmail.com

unread,
Nov 18, 2018, 2:13:10 AM11/18/18
to
Thanks a lot for your quick and essential answer. Sorry my for delay.
0 new messages