2

I'm puzzled. I have 2 versions of libssl.so in /lib: /lib/libssl.so.4 and /lib/libssl.so.6

Here is a stripped down minimal example -- I'm linking "nothing" with libssl -- the result being that it links to libssl.so.4. What determines this?

 $ g++ -o foo.so -shared -lssl

 $ ldd foo.so |grep ssl
 libssl.so.4 => /lib/libssl.so.4 (0xf7f04000)
osgx
  • 90,338
  • 53
  • 357
  • 513
c-urchin
  • 4,344
  • 6
  • 28
  • 30
  • Is `/lib/libssl.so` or `/usr/lib/libssl.so` a symbolic link to `/lib/libssl.so.4`? Also, see [this question](http://stackoverflow.com/questions/3840218/how-to-specify-the-library-version-to-use-at-link-time). – rlibby Apr 28 '11 at 15:32
  • yes, you are correct, /usr/lib/libssl.so is a symlink to /lib/libssl.so.4 (actually to the real file to which /lib/libssl.so.4 is itself a symlink.) Repointing solved the problem. – c-urchin Apr 30 '11 at 14:57

2 Answers2

4

The option -lssl instructs the linker to look for the file named libssl.so or libssl.a. If all you have are libssl.so.4 and libssl.so.6, then you would have a linker error.

Look for a symlink called "libssl.so" somewhere in your library directories, likely in /lib.

Cubbi
  • 46,567
  • 13
  • 103
  • 169
  • Thanks, I should have realized this. What threw me is that I expected the libssl.so symlink to be in the same directory as the actual files (which was /lib), but it was actually in /usr/lib, and of course pointed to the .so.4 version in /lib. Repointing it was the solution. – c-urchin Apr 30 '11 at 14:53
2

Option -lssl looks for linker library name, in that case it is libssl.so. Typically libssl.so would be a symlink pointing to soname library or real name library whith which actual linking is done. You should repoint libssl.so symlink to correct version of using lib.

More about shared labrary naming you can read here.

beduin
  • 7,943
  • 3
  • 27
  • 24
  • Thanks, this is exactly correct. I'd like to have marked this and @Cubbi's both as the selected answer but I had to choose one. – c-urchin Apr 30 '11 at 14:52