Connecting Tech Pros Worldwide Forums | Help | Site Map

Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

Visa Inquirer
Guest
 
Posts: n/a
#1: Apr 10 '08
I need my program to always link to a particular shared library, not
the one in LD_LIBRARY_PATH.

Is there a way to specify shared library by full path when linking so
that when running LD_LIBRARY_PATH is ignored?

Ian Collins
Guest
 
Posts: n/a
#2: Apr 10 '08

re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH


Visa Inquirer wrote:
Quote:
I need my program to always link to a particular shared library, not
the one in LD_LIBRARY_PATH.
>
LD_LIBRARY_PATH is both evil and off topic. Try comp.unix.programmer.

--
Ian Collins.
Gordon Burditt
Guest
 
Posts: n/a
#3: Apr 10 '08

re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH


>Beyond that... well, it would probably be better for you to ask in
Quote:
>a forum that has an idea of what LD_LIBRARY_PATH is. LD_LIBRARY_PATH
>is not part of standard C, and is very unlikely to become part of
>standard C (the name conflicts with the namespace reserved for
>user programs).
The name conflicts in *WHAT* namespace? I don't see any place
in the C standard where environment variable names are reserved for
user programs.

Antoninus Twink
Guest
 
Posts: n/a
#4: Apr 10 '08

re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH


On 10 Apr 2008 at 21:11, Visa Inquirer wrote:
Quote:
I need my program to always link to a particular shared library, not
the one in LD_LIBRARY_PATH.
>
Is there a way to specify shared library by full path when linking so
that when running LD_LIBRARY_PATH is ignored?
You can set the program's rpath: this will hard code a dynamic library
search path into your binary, and on most systems this will override
LD_LIBRARY_PATH.

With gcc, you can provide
-rpath dir
as an option when linking, and this will add dir to the executable's
run-time link path.

You should be aware that setting the rpath can cause all sorts of
problems if your program is installed by people who want to install
their libraries somewhere other than your preferred hard-coded search
path.

Walter Roberson
Guest
 
Posts: n/a
#5: Apr 10 '08

re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH


In article <ssSdnQreJuztEGPanZ2dnUVZ_ofinZ2d@internetamerica> ,
Gordon Burditt <gordonb.je2j0@burditt.orgwrote:
Quote:
Quote:
>>Beyond that... well, it would probably be better for you to ask in
>>a forum that has an idea of what LD_LIBRARY_PATH is. LD_LIBRARY_PATH
>>is not part of standard C, and is very unlikely to become part of
>>standard C (the name conflicts with the namespace reserved for
>>user programs).
Quote:
>The name conflicts in *WHAT* namespace? I don't see any place
>in the C standard where environment variable names are reserved for
>user programs.
The original poster made no indication that LD_LIBRARY_PATH was
an environment variable, only that it was a name whose value
the poster wished to be ignored.

--
"Not the fruit of experience, but experience itself, is the end."
-- Walter Pater
Walter Roberson
Guest
 
Posts: n/a
#6: Apr 11 '08

re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH


In article <slrnfvt4fr.vaf.nospam@nospam.invalid>,
Antoninus Twink <nospam@nospam.invalidwrote:
Quote:
>On 10 Apr 2008 at 21:11, Visa Inquirer wrote:
Quote:
>I need my program to always link to a particular shared library, not
>the one in LD_LIBRARY_PATH.
>>
>Is there a way to specify shared library by full path when linking so
>that when running LD_LIBRARY_PATH is ignored?
Quote:
>You can set the program's rpath: this will hard code a dynamic library
>search path into your binary, and on most systems this will override
>LD_LIBRARY_PATH.
Most systems? I dunno about that. Certainly not on the system I'm
using now -- here the -rpath ld option *adds* the given directory
to the search path, but does not override LD_LIBRARY_PATH (or the
system variations therein such as LD_LIBRARY64_PATH). On the system
I'm using, you have to link with -no_library_replace to prevent
the path specified in the binary from being overridden.
--
"There's no term to the work of a scientist." -- Walter Reisch
Closed Thread


Similar C / C++ bytes