in reply to programatically setting the LD_LIBRARY_PATH
Note that doing a Super Search for articles that mention LD_LIBRARY_PATH might have gotten you enough information to get past this problem. I didn't find the answer neatly wrapped up (but I only looked at a couple of the hits), though, so here is one...
You likely can't set LD_LIBRARY_PATH from within the running process no matter how early you do it as the linker/loader has already started loading the process and has cached the value of LD_LIBRARY_PATH. Previously I've work around this by execing the perl executable so that it must reload and will see the new LD_LIBRARY_PATH that I have set. On some operating systems, even that isn't enough as the linker/loader notices that we are execing the same executable and doesn't bother to reinitialize. For such cases, you have to exec a different executable and ask it to exec perl for you.
Something close to the following should work:
- tye (but my friends call me "Tye")BEGIN { my $need= '/usr/local/sybase/lib'; my $ld= $ENV{LD_LIBRARY_PATH}; if( ! $ld ) { $ENV{LD_LIBRARY_PATH}= $need; } elsif( $ld !~ m#(^|:)\Q$need\E(:|$)# ) { $ENV{LD_LIBRARY_PATH} .= ':' . $need; } else { $need= ""; } if( $need ) { exec 'env', $^X, $0, @ARGV; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: programatically setting the LD_LIBRARY_PATH
by GhodMode (Pilgrim) on Apr 08, 2004 at 13:16 UTC | |
by gordoste (Initiate) on Nov 29, 2005 at 04:23 UTC | |
by runrig (Abbot) on Mar 13, 2012 at 16:43 UTC | |
by Anonymous Monk on Mar 26, 2008 at 15:23 UTC | |
|
Re^2: programatically setting the LD_LIBRARY_PATH
by mikeraz (Friar) on Jan 26, 2006 at 17:10 UTC | |
|
Re: (tye)Re: programatically setting the LD_LIBRARY_PATH
by LanceDeeply (Chaplain) on Nov 21, 2001 at 00:39 UTC | |
|
Re^2: programatically setting the LD_LIBRARY_PATH
by shagbark (Acolyte) on Aug 09, 2013 at 17:17 UTC | |
by runrig (Abbot) on Aug 09, 2013 at 17:30 UTC |