Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Augmenting LD_LIBRARY_PATH at runtime
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



Report this thread to moderator Post Follow-up to this message
Old Post
Ashu
06-02-05 02:02 PM


Re: Augmenting LD_LIBRARY_PATH at runtime
Ashu 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


Report this thread to moderator Post Follow-up to this message
Old Post
bobroberts
06-02-05 08:58 PM


Re: Augmenting LD_LIBRARY_PATH at runtime
"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

Report this thread to moderator Post Follow-up to this message
Old Post
Måns Rullgård
06-02-05 08:58 PM


Re: Augmenting LD_LIBRARY_PATH at runtime
"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



Report this thread to moderator Post Follow-up to this message
Old Post
Ashu
06-02-05 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.