Linking to a so

Jun 20, 2014 at 5:08am
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 Jun 20, 2014 at 9:34am
Jun 20, 2014 at 1:57pm
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
Jun 20, 2014 at 5:05pm
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 Jun 20, 2014 at 8:13pm
Jun 20, 2014 at 8:46pm
Jun 21, 2014 at 10:00pm
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.
Jun 22, 2014 at 3:32pm
Why are you using the .exe extension in a Unix , in fact you don't need a suffix at all.
Last edited on Jun 22, 2014 at 3:32pm
Jun 22, 2014 at 7:08pm
You could let the user link your program against his version of the library
Jun 23, 2014 at 8:28am
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.
Jun 27, 2014 at 10:45pm
May you should use command "ldconfig" to clear caches of libraries
Topic archived. No new replies allowed.