Unix Programming - Dynamic path for shared libraries

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > Dynamic path for shared libraries





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Dynamic path for shared libraries
Apprentice

2006-04-02, 7:42 pm

Hi there,
Is there a way in which I can specify at runtime to an application
the locations of shared dynamic libraries on which it depends? I do
not want to use LD_LIBRARY_PATH or other LD constructs.
My Shared libraries can be placed any place on the system by the end
user and I would like to use shared libraries from that location as
specified by user in a config file or as command line arguments .
I needed this, since I want my applications to be very portable
across platforms and install locations.
I would really appreciate all the help I can get on this. Thanks your
time..

Dhanvi

Frank Cusack

2006-04-02, 7:42 pm

On 27 Mar 2006 12:27:51 -0800 "Apprentice" <ekzindagi@gmail.com> wrote:
> Hi there,
> Is there a way in which I can specify at runtime to an application
> the locations of shared dynamic libraries on which it depends? I do
> not want to use LD_LIBRARY_PATH or other LD constructs.
> My Shared libraries can be placed any place on the system by the end
> user and I would like to use shared libraries from that location as
> specified by user in a config file or as command line arguments .
> I needed this, since I want my applications to be very portable
> across platforms and install locations.


crle on Solaris, ldconfig on Linux.

Better is $ORIGIN on Solaris. I've heard that Linux has it but I
don't know for sure.

-frank
Paul Pluzhnikov

2006-04-02, 7:42 pm

Frank Cusack <fcusack@fcusack.com> writes:

> On 27 Mar 2006 12:27:51 -0800 "Apprentice" <ekzindagi@gmail.com> wrote:

No, because the app will not even start (will not get to the
first line of main()) if the dynamic loader can't find its needed
libraries.

The usual way to deal with this is a shell wrapper, which sets
LD_LIBRARY_PATH properly, then invokes the real executable.

Or are you objecting to LD_... on philosophical grounds?
[vbcol=seagreen]

Your app can't start, so it can't read config file or command line
args yet. OTOH, the shell script can set proper LD_LIBRARY_PATH
based on either.
[vbcol=seagreen]

Usually applications specify that they have to be installed in some
single location (as a whole tree). In that case, the relative path
from binaries to shared libraries is fixed, and '$ORIGIN' allows you
to do away with the shell wrapper.

However, '$ORIGIN' exists only on Solaris and Linux (it may exist
on other platforms which I do not regularly deal with).

It (or equivalent) does not exist on HP-UX/PA-RISC, nor on AIX.
[vbcol=seagreen]
> crle on Solaris, ldconfig on Linux.


Both require root privileges. If the installer has root privilege,
he may as well install libraries into /usr/lib.

> Better is $ORIGIN on Solaris. I've heard that Linux has it but I
> don't know for sure.


Yes, it exists and works on Linux (since at least RedHat 6.2).

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Apprentice

2006-04-02, 7:42 pm

Hi Paul ,
Thanks for the help..

Paul Pluzhnikov wrote:
>
> Usually applications specify that they have to be installed in some
> single location (as a whole tree). In that case, the relative path
> from binaries to shared libraries is fixed, and '$ORIGIN' allows you
> to do away with the shell wrapper.


Please can you gimme more details on how this can be done ? Is $ORIGIN
something I need to specify during my build process ?

Thanks,
Dhanvi

Paul Pluzhnikov

2006-04-02, 7:42 pm

"Apprentice" <ekzindagi@gmail.com> writes:

> Please can you gimme more details on how this can be done?


http://docs.sun.com/app/docs/doc/81...24ORIGIN&a=view
Scroll down to "Locating Associated Dependencies".

> Is $ORIGIN
> something I need to specify during my build process ?


Yes.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com