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

Re: LD_LIBRARY_PATH under Linux



On Tue, Apr 11, 2006 at 11:23:00PM -0400, T wrote:
> On Tue, 11 Apr 2006 21:17:44 -0400, Roberto C. Sanchez wrote:
> 
> >> We used the environment var LD_LIBRARY_PATH to give preference/order of
> >> the libraries that we use. Does this still applied to Linux?
> >> 
> >> I tried to do it under Linux but didn't success. Here is what I tried:
> >> 
> >> [...]
> > 
> > It should work.  The way to be sure which library is being loaded is to
> > export the LD_LIBRARY_PATH variable the way you want it and then run `ldd
> > /opt/old/usr/bin/transcode` to see where it finds the shared libraries.
> 
> thanks. Roberto for the reply. I am now confirmed that it is not the
> LD_LIBRARY_PATH's problem. Maybe transcode is looking for its libs in a
> fixed location or something. 
> 

> Is there any way to specify transcode command line parameter when probing
> with ldd? --

wouldn't make much sense, as the program isn't really being run...


> which lib for transcode to load depends on its parameter...

now this very much sounds like the program is using dlopen(3) to load
the library at runtime, after having determined which one to load.

In this case, if the authors have decided to pass an absolute path to
dlopen, you're essentially out of luck (you could still try to patch
the binary, or recompile -- but well...).  To further inspect what's
going on, you might want to try ltrace(1) or strace(1) -- most likely
won't help much, though, to actually _control_ which lib gets loaded...


BTW, for the sake of completeness: LD_LIBRARY_PATH will have no effect,
if the executable has been linked using the "rpath" option, because any
RPATHs will be searched before the ones specified in LD_LIBRARY_PATH
(don't really think this is your problem, but just in case...).

If unsure, use "readelf -d | grep RPATH" (or "objdump -x | grep RPATH")
to check whether any RPATHs have been compiled into the binary  (both
programs belong to the binutils package).

To override RPATH settings, you should usually be able to explicitly
preload the librarie(s) in question using LD_PRELOAD (see "man ld.so"
for the nitty-gritty details).  In this case, any symbols provided by
the preloaded library will serve to satisfy symbol requests directly,
thus preventing that same library from being loaded from some other
undesired location.


Good luck,
Almut



Reply to: