Code Comments
Programming Forum and web based access to our favorite programming groups.Is there a way to augment the LD_LIBRARY_PATH at runtime, or achieve the
same effect through any other means?
(setenv("LD_LIBRARY_PATH",...) does not work at runtime).
The problem faced is this:
Library libABC.so is linked against libXYZ.so, and both are finally kept in
the same directory.
An application knows the location of libABC.so and dlopen()s it (giving the
full path). The call, however, fails because the directory containing
libXYZ.so is not in LD_LIBRARY_PATH and so libXYZ.so can not be found.
Is there a way to dlopen libABC.so although LD_LIBRARY_PATH is inadequate as
regards the location of libXYZ.so?
The application is a third-party one, and so I cannot modify its launch
behaviour (such as wrapping it in a script which first sets LD_LIBRARY_PATH
correctly). It is actually our plugin in that application which needs to
dlopen libABC.so.
Even if there's a Linux-only solution, it would be very helpful.
Thanks,
Ashu
Post Follow-up to this messageAshu wrote:
> Is there a way to augment the LD_LIBRARY_PATH at runtime,
> or achieve the same effect through any other means?
> (setenv("LD_LIBRARY_PATH",...) does not work at runtime).
>
> The problem faced is this:
>
> Library libABC.so is linked against libXYZ.so, and both
> are finally kept in the same directory.
> An application knows the location of libABC.so and
> dlopen()s it (giving the full path). The call, however,
> fails because the directory containing libXYZ.so is not in
> LD_LIBRARY_PATH and so libXYZ.so can not be found.
>
> Is there a way to dlopen libABC.so although
> LD_LIBRARY_PATH is inadequate as regards the location of
> libXYZ.so?
>
I'm a little
. You said that libXYZ.so is in the same directory
as libABC.so and that you open libABC.so using the fully qualified
path. Since ABC depends on XYZ, can't you just use dlopen to open XYZ
first and once it is loaded, then open libABC.so? I would think the
dependency would be satisfied then...
the dlopen(3) man page says:
External references in the library are resolved using the
libraries in that library's dependency list and any other
libraries previously opened with the RTLD_GLOBAL flag
If I've misunderstood the issue, I apologize for wasting your time...
good luck :)
-bob
Post Follow-up to this message"Ashu" <ashusharma@gmail.com> writes:
> Is there a way to augment the LD_LIBRARY_PATH at runtime, or achieve the
> same effect through any other means?
> (setenv("LD_LIBRARY_PATH",...) does not work at runtime).
>
> The problem faced is this:
>
> Library libABC.so is linked against libXYZ.so, and both are finally kept i
n
> the same directory.
> An application knows the location of libABC.so and dlopen()s it (giving th
e
> full path). The call, however, fails because the directory containing
> libXYZ.so is not in LD_LIBRARY_PATH and so libXYZ.so can not be found.
>
> Is there a way to dlopen libABC.so although LD_LIBRARY_PATH is inadequate
as
> regards the location of libXYZ.so?
>
> The application is a third-party one, and so I cannot modify its launch
> behaviour (such as wrapping it in a script which first sets LD_LIBRARY_PAT
H
> correctly). It is actually our plugin in that application which needs to
> dlopen libABC.so.
If you dlopen libXYZ.so first, with the RTLD_GLOBAL flag, everything
should be fine. There may of course be reasons you don't want to do
this. If you have control over how libABC.so is built, you can add
the correct directory to its DT_RUNPATH section (see linker
documentation for how to do that).
--
Måns Rullgård
mru@inprovide.com
Post Follow-up to this message"Ashu" <ashusharma@gmail.com> wrote in message
news:IZxne.8577$Cz3.1029334@monger.newsread.com...
> Is there a way to augment the LD_LIBRARY_PATH at runtime, or achieve the
> same effect through any other means?
> (setenv("LD_LIBRARY_PATH",...) does not work at runtime).
>
> The problem faced is this:
>
> Library libABC.so is linked against libXYZ.so, and both are finally kept
in
> the same directory.
> An application knows the location of libABC.so and dlopen()s it (giving
the
> full path). The call, however, fails because the directory containing
> libXYZ.so is not in LD_LIBRARY_PATH and so libXYZ.so can not be found.
>
> Is there a way to dlopen libABC.so although LD_LIBRARY_PATH is inadequate
as
> regards the location of libXYZ.so?
>
> The application is a third-party one, and so I cannot modify its launch
> behaviour (such as wrapping it in a script which first sets
LD_LIBRARY_PATH
> correctly). It is actually our plugin in that application which needs to
> dlopen libABC.so.
>
> Even if there's a Linux-only solution, it would be very helpful.
>
> Thanks,
> Ashu
>
>
Thanks Måns and Bob.
Loading the dependencies first would solve the problem (in the actual case,
the number is quite high). And so would using -rpath when linking libABC.so.
Thanks,
Ashu
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.