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

I had to use a call to asin() in a script. When I tested it at home everything worked perfectly but when it was tried on a remote site the following message appeared:

Can't locate loadable object for module POSIX \ in @INC (@INC contains: ... .) at /app/foo/master/bin/well_summary_gcrt line 29 BEGIN failed--compilation aborted at \ /app/foo/master/bin/well_summary_gcrt line 29

Looking at the remote site I found that the POSIX.so file had not been copied. Now I know that I should have copied this file, and I can dispatch a copy of it without any problems. But being a cautious person I want to test this out at home before sending off the file.

I have looked in $PERLLIB, $PERL5LIB and $LD_LIBRARY_PATH and none of them point to a location that contains the POSIX.so file. The path that was compiled into Perl at build time no longer exists, I don't have a /lib/perl or /usr/lib/perl. Yet my script keeps finding the POSIX.so file.

What am I missing? How is Perl managing to locate this file? How can I make my script fail?

Replies are listed 'Best First'.
Re: Finding loadable objects (script refuses to fail)
by robartes (Priest) on Mar 12, 2003 at 14:23 UTC
    I'd hazard a guess that XSLoader.pm is smart enough to figure out that the POSIX.so file is in the auto/POSIX directory below the directory where POSIX.pm is found. Wit this snippet of code from XSLoader.pm:
    my @modparts = split(/::/,$module); my $modfname = $modparts[-1]; my $modpname = join('/',@modparts); my $modlibname = (caller())[1]; my $c = @modparts; $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext";
    Later on it does a dl_load_file of $file, which for POSIX.pl will contain <directory containing POSIX.pm>/auto/POSIX/POSIX.so. So, if your script can find POSIX.pm, it can find POSIX.so.

    This is just a naieve browsing of XSLoader and POSIX.pm code, however, so I might be wrong. You will find some salt in the monastery's kitchen :).

    CU
    Robartes-

      That was sort of what I was thinking should happen, but I changed the name of POSIX.so near the POSIX.pm file to POSIX.so.b to try and emulate the remote site's situation. But the script still did not fail here. Somehow it manages to load POSIX.so from somewhere whatever I do.

      I am working on Solaris so naturally I can't unmount all the disks or pull the network cable (or even do a find from /).

      I know that Perl is powerfull but this is starting to make me seriously question my sanity. Where does it find it?

Re: Finding loadable objects (script refuses to fail)
by PodMaster (Abbot) on Mar 12, 2003 at 14:36 UTC
    If you encounter that error, and POSIX.so is in the right spot, make sure $ENV{PATH} contains the path to the perl binary running the script (File::Basename::dirname($^X) ought to be it -- this happened to me a few times under apache/mod_perl).

    When copying files from machine, look into ExtUtils::Installed, ExtUtils::Packlist, and PPM.

    When dealing with modules downloadable from cpan (ie, you do the make dance), and you have a blib directory, simply copy that entire blib directory, and do a use blib 'my/dir/where/blib/is' (tar -zxvf Dist-Name.tar.gz blib, and you've got yourself a ppm package, do a make ppd, and you got the ppd file describing it -- you'll need to edit it though)

    Or if you're root, use perl -MExtUtils::Install -e install_default Dist/Name to install Dist/Name, assuming there is a blib dir built by ExtUtils::MakeMaker in the current dir.

    Try this oneliner

    perl -MExtUtils::Installed -le " print for grep { /Posix/i } ExtUtils: +:Installed->new->files(q[Perl]) "


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: Finding loadable objects (script refuses to fail)
by chromatic (Archbishop) on Mar 12, 2003 at 17:58 UTC

    POSIX uses XSLoader to load a C extension. There's some scary magic in there to find the .so file.

Re: Finding loadable objects (script refuses to fail)
by hawtin (Prior) on Mar 12, 2003 at 15:15 UTC

    Well I managed to find the POSIX.so file it was loading by changing the name of every one I could find. This allowed me to confirm that copying this file to a single location would fix the issue.

    I still have no idea how it managed to find the particular one it was using (near where Perl was built originally). If any brother could illuminate me on this point I would be happy.

    I would like to thank both those brothers that provided input.