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

I, unfortunately, am working on a machine where perl needs to be installed at '/foo/bin/perl' and the libraries are under '/foo/lib/perl5'. I keep getting errors that certain perl modules can't be loaded. I'll add something to a BEGIN statement pushing them onto @inc, but that just seems to get me a different error message (currently it's "can't find DynaLoader.pm"). I tried making a link to /usr/local/lib, which is where it seems to be looking, but had no luck with that.

thanks for any help.

Replies are listed 'Best First'.
Re: perl can't find my modules
by blakem (Monsignor) on Sep 07, 2001 at 22:38 UTC
    Sounds like there are actually two problems here... the oracle library has already been dealt with, so I'll just address the other one.

    If you have modules installed in a non-standard place, the $PERL5LIB environment variable is your friend. When set, it will eliminate the need to put use lib '/somewhere/odd' in all of your scripts. Of course, it takes a little prep work to ensure that $PERL5LIB is always being set in whatever environment the script is being executed, but it will be well worth the time down the road.

    -Blake

      To be complete, a popular way to do this is to make a 'wrapper' for perl. Usually this is a shell script. Move perl out of the way, and replace it with a script similar to this:

      #!/bin/sh #Wrapper to set perl env variables export PERL5LIB=/path/to/modules /path/to/where/perl/really/is/perl

      Make sure the script is called perl and has the right permissions (chmod a=rx). This is a very convenient way to tweak the environment for scripts before they run.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

Re: perl can't find my modules
by dragonchild (Archbishop) on Sep 07, 2001 at 21:52 UTC
    What version of Perl?

    What is the exact error statement (cut'n'pasted from your terminal)?

    Have you tried doing a use lib 'My/Dir/Here'; yet? (That prolly won't work, but it's worth a try...)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Perl version: 5.005_03 built for sun4-solaris

      Exact error stmt:
      Can't load '/raid/blah/env/local/lib/perl5/site_perl/5.005/sun4-solaris//auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: ld.so.1: /blah/env/local/bin/perl: fatal: libclntsh.so.1.0: open failed: No such file or directory at /blah/env/local/lib/perl5/5.00503/sun4-solaris//DynaLoader.pm line 169.
      at ./prog.pl line 40
      BEGIN failed--compilation aborted at ./prog.pl line 40.

      I did try 'use lib' but couldn't make that work.

      Thanks.

        According to your logs, DynLoader.pm has been found but can't find libclntsh.so.1

        It seems to be an oracle library. You should set LD_LIBRARY_PATH environment variable or it Solaris equivalent to include the directory path that contains the said library. Or add this path to /etc/ld.so.conf and runs ldconfig (if Solaris works like linux).

        Good Luck.

        -- stefp