[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to link against non-public shared libraries?



Milan Zamazal <pdm@debian.org> writes:

> My package contains binaries using a common shared library, which is not
> intended to be used by other programs.  This is a regular shared
> library, not a plugin or other object to be explicitly loaded by the
> binaries, the binaries just normally link to it.
>
> Debian Policy says:
>
>      Shared object files (often `.so' files) that are not public libraries,
>      that is, they are not meant to be linked to by third party executables
>      (binaries of other packages), should be installed in subdirectories of
>      the `/usr/lib' directory.  Such files are exempt from the rules that
>      govern ordinary shared libraries, except that they must not be
>      installed executable and should be stripped.[2]
>
> So the shared library should be put into /usr/lib/SOMETHING/, which is
> of course a non-standard path for the linker.
>
> My question is: How to ensure properly that the binaries can find the
> library?  I can think of several solutions (putting the library into
> /usr/lib/, modifying /etc/ld.so.conf, using -rpath), but I'm not sure

- /usr/lib would be a policy violation if its not a public library.

- modifying /etc/ld.so.conf is ugly and dangerous.

- using -rpath means that library updates won't work without binary
updates. Assuming that both library and binaries are from the same
source or even in the same binary package this is not an issue and the
best solution.

- using LD_PRELOAD or LD_LIBRARYPATH works but is ugly and needs
a wrapper script for every binary.

> which of them is the right one.  I tried to RTFM and to find a similar
> case in another package, but without success.

I would say rpath.

> Thanks for an appropriate pointer to documentation or other advice.
>
> Milan Zamazal

MfG
        Goswin



Reply to: