PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > Linking with a particular shared library by full path overridingLD_LIBRARY_PATH
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

Réponse
 
LinkBack Outils de la discussion
Vieux 10/04/2008, 22h11   #1
Visa Inquirer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

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?
  Réponse avec citation
Vieux 10/04/2008, 22h22   #2
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

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
  Réponse avec citation
Vieux 10/04/2008, 22h25   #3
Ian Collins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

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.
  Réponse avec citation
Vieux 10/04/2008, 22h58   #4
Gordon Burditt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
>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.

  Réponse avec citation
Vieux 10/04/2008, 23h17   #5
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Linking with a particular shared library by full path overriding LD_LIBRARY_PATH

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.

  Réponse avec citation
Vieux 10/04/2008, 23h18   #6
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Linking with a particular shared library by full path overridingLD_LIBRARY_PATH

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
  Réponse avec citation
Vieux 11/04/2008, 00h02   #7
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Linking with a particular shared library by full path overriding LD_LIBRARY_PATH

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h25.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17422 seconds with 15 queries