Linking to a so

Hi all,

currently I'm facing a issue in linking a .so file.

In my build machine, I've libcrypto.so.6 and there is a softlink as libcrypto.so.

In my make file I'm trying to link to the lib using -L -lcrypto and it is success and created my test.exe.

When I copy this test.exe to other machine, there libcrypto.so is present but it is looking for libcrypto.so.6. Due to which the exe is not coming up.

Eg: ldd -r test.exe

libcrypto.so.10 => /usr/lib/libcrypto.so.10 (0x00f69000)

But my as per my understanding this should point to
libcrypto.so => /usr/lib/libcrypto.so.10 (0x00f69000)
How to resolve this problem and what is happening internally.

Thanks
Vijay
Last edited on
You can statically link. That is, link to libcrypto.a.

You can do that by telling the linker you need a static link. You need to pass -Wl,-Bstatic -lcrypto
There's a reason why the number is appended. It is a file link, yes, but it does correctly indicate ABI version.

https://www.flameeyes.eu/autotools-mythbuster/libtool/version.html

You can probably only link to version 10 as others would most likely break your code anyways.
Last edited on
It you continue to use shared libs, you'll continue to have the problem of other systems not having the same version of stuff that's on your build machine.
Why are you using the .exe extension in a Unix , in fact you don't need a suffix at all.
Last edited on
You could let the user link your program against his version of the library
You could let the user link your program against his version of the library
That's fine as long as the library is both backward and forward compatible. There's only one case where I've seen that principle applied.
May you should use command "ldconfig" to clear caches of libraries
Topic archived. No new replies allowed.