|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
In article <e677624c-ae8f-468a-a896-94e398efbaeb@l64g2000hse.googlegroups.com>,
Visa Inquirer <visa_desirer@yahoo.com> wrote: >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? There are often ways to link shared libraries "statically" -- to bring the entire shared library in to an executable as if it had originally been a non-shared library. If you did that, then any dynamic library search path would not matter, as the library would not be listed as needing to be dynamically found. 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). Perhaps you want a general unix programming group, or perhaps you want a programming group specific to whatever OS you are using. I could give you the answer for the system I'm using right now, but I have no idea whether the solution would work for whatever OS you are using (probably not, though.) -- "When we all think alike no one is thinking very much." -- Walter Lippmann |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Visa Inquirer wrote:
> 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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
>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). 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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On 10 Apr 2008 at 21:11, Visa Inquirer wrote:
> 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. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
In article <ssSdnQreJuztEGPanZ2dnUVZ_ofinZ2d@internetamerica> ,
Gordon Burditt <gordonb.je2j0@burditt.org> wrote: >>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). >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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
In article <slrnfvt4fr.vaf.nospam@nospam.invalid>,
Antoninus Twink <nospam@nospam.invalid> wrote: >On 10 Apr 2008 at 21:11, Visa Inquirer wrote: >> 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. 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 |
|
![]() |
| Outils de la discussion | |
|
|