[OPEN-ILS-DEV] LD_LIBRARY_PATH Discussion

Mike Rylander mrylander at gmail.com
Mon May 14 15:00:24 EDT 2007


On 5/14/07, Dan Wells <dbw2 at calvin.edu> wrote:
> Hello,
>
> I'm starting a new thread rather than continuing to hijack the old one.
>
> >Mike Rylander said:
> >Second, and really only for explanation's sake, some .so's don't start
> >with lib because they are only ever dlopen'd, meaning that they'll
> >never be linked directly into any program or library.
>
> If I do not set the LD_LIBRARY_PATH, I get a bunch of errors like this:
> Failed to dlopen library file oils_cstore.so: oils_cstore.so: cannot open
> shared object file: No such file or directory
>
> Is there another way to address these issues, or is this an acceptable use of
> this variable?  Should I use DYLD_LIBRARY_PATH or even
> DYLD_FALLBACK_LIBRARY_PATH instead to catch these non-linked shared object
> files which are not caught by ldconfig?

Looking at the dlopen man page (on my Linux system, at least) it looks
like using the full path to the .so should work.  Obviously, this is
not a general solution today since there is not templating in the
default config file, but some sed magic that used the environment vars
from set up via configure (currently make config) (oh, and $PREFIX
should be enough) and could be integrated into a makefile
(*hint-hint*) would be one route to doing this, and would be
technically more secure.

For reference, here's the relevant part of the man page:

-----------------

       The function dlopen() loads the dynamic library file named by
the null-terminated string filename and returns an opaque "handle" for
the dynamic library.   If filename  is  NULL,  then the returned
handle is for the main program.  If filename contains a slash ("/"),
then it is interpreted as a (relative or absolute) pathname.
Otherwise, the dynamic linker searches for the library as follows (see
ld.so(8) for further details):


       o      (ELF only) If the executable file for the calling
program contains a DT_RPATH tag, and does not contain a DT_RUNPATH
tag, then the  directories  listed
              in the DT_RPATH tag are searched.

       o      If  the environment variable LD_LIBRARY_PATH is defined
to contain a colon-separated list of directories, then these are
searched.  (As a security mea-
              sure this variable is ignored for set-user-ID and
set-group-ID programs.)

       o      (ELF only) If the executable file for the calling
program contains a DT_RUNPATH tag, then the directories listed in that
tag are searched.

       o      The cache file /etc/ld.so.cache (maintained by
ldconfig(8)) is checked to see whether it contains an entry for
filename.

       o      The directories /lib and /usr/lib are searched (in that order).



-- 
Mike Rylander


More information about the Open-ils-dev mailing list