At 2004-09-04T23:36:02+1200, Volker Kuhlmann wrote:

> Yes, but that's not with -lXY.

Correct.  It's not exactly what you were after, but it may be close
enough to get the results you need.

> I take it there isn't any way to use the linker library search path
> when one needs a specific .so version, and one has to use absolute
> paths and full names. Oh well, it works...

I don't know of one yet.

Note that while you are specifying an absolute path to a particular SO
on the command-line in this case, it's not resulting in that particular
absolute path being required during run-time linking (this aspect would
be affected by ld's -rpath option).

You can achieve the same effect in other ways, e.g. on a system where
linking against libssl.so will get you 0.9.7 by default:

$ ln -s /usr/lib/libssl.so.0.9.6 libssl.so
$ cc x.c -L. -lssl
$ ldd a.out | grep ssl
    libssl.so.0.9.6 => /usr/lib/i686/cmov/libssl.so.0.9.6 (0x4002500)

...but this is quite a hack. 

What complicates things more is that the compile-time linking is
recording the SONAME of the library you're linking against (0.9.6/0.9.7
in the case of libssl).  During run-time linking, the first suitable
library found by the linker with a matching SONAME will be used.

My example with libssl may not have been the best choice, as OpenSSL has
a bit of bad history with SONAME handling.  Most libraries will have a
SONAME more like libblah.so.1 (rather than libblah.so.1.0.1).  What this
means is that, at link-time, you could specify an absolute path to a
specific major.minor.revision SO, e.g.:

$ cc x.c /path/to/libblah.so.1.0.1

...but the SONAME is recorded in your executable, so during run-time
linking, the linker may find that libblah.so.1.0.2 has a SONAME of
libblah.so.1, so is considered a final matching candidate for that
library.

If you want to know how to use a specific major.minor.revision SO even
when a different version with the same SONAME is available (and the most
likely candidate) on your system, it becomes even trickier still.

Cheers,
-mjg
-- 
Matthew Gregan                     |/
                                  /|                [EMAIL PROTECTED]

Reply via email to