C: How to communicate with different versions of the library at the same time

I am creating a dynamic library ( libfoo.so) that requires libcrypto.so. Which works great on the build platform (I create it in Ubuntu 16.04). However, when I transfer the same library to Debian Stretch 9.3, it starts complaining about the absence libcrypto.so.1.0.0. The openssl package is installed on Debian Stretch, but it libcrypto.sois called libcrypto.so.1.0.2. After a little digging, I found out that although libcrypto.soUbuntu 16.04 calls libcrypto.so.1.0.0(its SONAMEalso libcrypto.so.1.0.0), this is actually version 1.0.2.

Here's the question: I don’t want to recompile a special version for Debian, anyway, that my library can be used in both Linux distributions? Any link at the same time with the .so version or other methods?

I forgot to mention that I used the gcc compiler, my library is written in C.

+4
source share
2 answers

In my opinion (although I have not done it before) ... if you are not too worried about the size of your shared libfoo.so object ... I think your best bet here would be a static link libcrypto.a (a static version of libcrypto for your chosen version)

Although I suspect you might run into other c-libraries that don't play well between different distributions (Debian and Ubuntu) ... even if you had to make it work, it would be a nightmare

(The following value may not be appropriate if you load your .so object at run time into a program compiled on another machine)

... ,

https://unix.stackexchange.com/questions/227910/will-my-linux-binary-work-on-all-distros

- , , , , . X, , X .

+2

, .

libcrypto.so.1.0.0 patchelf, SONAME

patchelf --set-soname libcrypto.so libcrypto.so.1.0.0

, NEEDED libcrypto.so NEEDED libcrypto.so.1.0.0, Debian, Ubuntu.

, libcrypto.so, libcrypto.so.1.x.x

+1

Source: https://habr.com/ru/post/1694774/


All Articles