Building and linking shared libaries for multipledifferentversionsof UNIX

samba-technical at thewrittenword.com samba-technical at thewrittenword.com
Wed May 16 17:53:53 GMT 2001


On Wed, May 16, 2001 at 01:31:35PM -0400, Michael Sweet wrote:
> Steve Langasek wrote:
> > ...
> > If you're going to have versioned libraries, you'll also need to
> > pass an option to the linker to specify the versioned soname --
> > otherwise, programs which link against the library won't actually
> > know they need libFoo.so.93.
> 
> What we do is to link the DSO with the version number, e.g.:
> 
>     cc -shared -o libfoo.so.99 *.o
> 
> (this is a ficticious command, of course)
> 
> Then you make the symlink to .so (so the linker can find the DSO
> when you link the other apps), but the soname used is "libfoo.so.99".
> This isn't universally supported, so there is an added -soname (or
> whatever) in the DSO link on some platforms, but that is the basic
> idea.

If you make the soname the fully versioned name of the library, you
must be very careful about how you version the libraries. If you bump
the version number with every change, even when the API has not
changes, the user must have multiple versions installed (not one
version which exports the same ABI with maybe bugfixes).

I'd advise for an soname that is the same when the ABI is the same
even though the fully versioned library name might be different:
  libfoo.so -> libfoo.so.99.0
  libfoo.so.99 -> libfoo.so.99.0
  libfoo.so.99.0			[soname libfoo.so.99]

libfoo.so.99.x could also have soname libfoo.so.99.

-- 
albert chin (china at thewrittenword.com)




More information about the samba-technical mailing list