jimr451 has asked for the wisdom of the Perl Monks concerning the following question:

How can I set the @dl_library_path in the Dynaloader? I'm trying to install the Adobe FDF package in a local setup (no root access), and can't get the loader to find the libraries. Here's the message:

Can't load '/path_stripped/FDF.so' for module Acrobat::FDF: libFdfTk.so: cannot open shared object file: No such file or directory at /usr/lib/perl/5.6.1/DynaLoader.pm line 202. at /path_stripped/FDF.pm line 744

The FDF.so, and libFdrTk.so, and FDF.pm are all in the same directory. I've tried tracing the process, and it seems like it's only looking through the standard library paths for the file. I've tried "pushing" to the list, but can't seem to get that to work.

Thanks for any ideas.

-Jim

Replies are listed 'Best First'.
Re: Dynaloader library path
by chromatic (Archbishop) on Feb 13, 2006 at 21:01 UTC

    I believe you have to add to the array after DynaLoader loads but before your module tries to use it. That is, use DynaLoader in your code, extend the array in a BEGIN block, then use the module you want normally.

    An easier option is to set the appropriate environment variable, LD_LIBRARY_PATH before launching your process.

      Thanks - I'm getting closer. If I set the LD_LIBRARY_PATH in the shell, things seem to work.

      Problem is running it as a CGI, seems the the Apache environment isn't picking up the setting. I have a .profile and .bashrc setup, but no dice.

      Setting the $ENV hash within the script doesn't seem to do the trick either. Any ideas? I'm about to just post to an .sh script which calls the perl script!

      -Jim
        In Apache, you can use the PassEnv directive to pass along particular environment variables to the httpd server, see http://httpd.apache.org/docs/2.0/mod/mod_env.html#passenv

        This ought to let your CGI scripts see the LD_LIBRARY_PATH env variable. The vairable has to be set in the shell starting the httpd process, so make sure your shell script that starts Apache has the variable set/exported, if it isn't already so.

        -imran