CountOrlok has asked for the wisdom of the Perl Monks concerning the following question:
I have a Perl script that needs to load a module, foo.pm, which in turn uses XSLoader to load libfoo_perl.so. libfoo_perl.so has a reference to bar.so which is not in a standard path. I can not modify the environment variables before running my script. The script looks like this:
The above would give me an error like this: Can't load '/foo/bin/libfoo_perl.so' for module foo_perl: bar.so: cannot open shared object file: No such file or directory at /auto/perl/5.8.3/lib/5.8.3/i686-linux-thread-multi/DynaLoader.pm line 229.$ENV{PATH} = "/foo/bin:/bar/bin:$ENV{PATH}"; $ENV{LD_LIBRARY_PATH} = "/foo/bin:/bar/bin:$ENV{LD_LIBRARY_PATH}"; $ENV{PERL5LIB} = "/foo/lib:$ENV{PERL5LIB}"; use lib "/foo/lib"; use foo; # if I comment the above line and # uncomment below, it works, but that is not what I want. # print `perl -e 'use foo; print "success\n";'`;
I know the easy solution is to add the directory for bar.so to LD_LIBRARY_PATH, but I can not do that. I am not allowed to touch the environment outside the script. Only inside the script. And no, I can not recompile libfoo_perl.so to hard code the path to bar.so.
It would appear that the dl_load_file() function in DynaLoader does not inherit the current %ENV settings, and instead uses the parent environment settings.
Using Perl 5.8.3, if you haven't guessed already.
Thanks for the help,
Imran
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DynaLoader and LD_LIBRARY_PATH
by derby (Abbot) on Nov 10, 2005 at 17:21 UTC | |
by CountOrlok (Friar) on Nov 10, 2005 at 17:36 UTC | |
by derby (Abbot) on Nov 10, 2005 at 18:27 UTC | |
|
Re: DynaLoader and LD_LIBRARY_PATH
by Tanktalus (Canon) on Nov 10, 2005 at 18:06 UTC | |
by CountOrlok (Friar) on Nov 10, 2005 at 18:34 UTC | |
by Tanktalus (Canon) on Nov 10, 2005 at 18:38 UTC | |
|
Re: DynaLoader and LD_LIBRARY_PATH (link)
by tye (Sage) on Nov 11, 2005 at 03:35 UTC |