Re: dynamic LD_LIBRARY_PATH

Jan Dubois <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <CAD-TLz_5P47k1SbpGBW9Pyqp_Wp30a_e49TjKfSEwAnrKvFZAw@mail.gmail.com>
On Wed, Apr 16, 2014 at 8:15 AM, H.Merijn Brand <[email protected]> wrote:
> On Wed, 16 Apr 2014 17:06:19 +0200, "H.Merijn Brand"
> <[email protected]> wrote:
>
>> if I change Oracle.pm to start with
>> --8<---
>> BEGIN {
>>     use Config;
>>     (my $loc = $INC{"DBD/Oracle.pm"}) =~
>>       s{/DBD/Oracle.pm$}{/$Config{archname}/auto/DBD/Oracle};
>>     $ENV{LD_LIBRARY_PATH} = "$oloc:$ENV{LD_LIBRARY_PATH}";
>>     $ENV{SHLIB_PATH}      = "$oloc:$ENV{SHLIB_PATH}";
>>     }
>> -->8---
>>
>> I am still too late :( :(

I believe all the LD_* variables are only read once during process
startup. Setting them within the app will only affect any child
process started afterwards, but not change the behavior of the dynamic
loader inside the current process.

It's been probably 15 years ago, but for a similar problem with
DBD::Oracle on HP-UX back then we used a wrapper app that set
LD_PRELOAD to request specific libraries to be loaded, and then
exec'ed perl from that wrapper:

        ld_preload = (char *)malloc(strlen(libjava) + strlen(libcl) +
                                    strlen(libclnt) + 13);
        sprintf(ld_preload, "LD_PRELOAD=%s:%s:%s", libjava, libcl, libclnt);

        putenv(strdup(ld_preload));
        argv[0] = me;
        execvp(argv[0], argv);

Cheers,
-Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.