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:
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;
}
}
-
tye
(but my friends call me "Tye")
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|