Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Tweaking DynaLoader's path without write access to the perl installation

by mhi (Friar)
on May 30, 2004 at 20:58 UTC ( [id://357671]=perlquestion: print w/replies, xml ) Need Help??

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

Dear fellow Monks,

does anyone know how to change the DynaLoader's libpath from within the perl script that wants to use a library through the DynaLoader?

Background is this:

I have some perl scripts hosted on a webserver where I do not have control over the perl installation and therefore can not properly install perl add-ons. For static modules this is not a problem as I can use lib "/mypath"

This however does not seem to work for stuff that needs the DynaLoader, like use ccom. There I consistently get the message

$ Can't load '/mypath/auto/ccom/ccom.dll' for module ccom: load_file:T +he specified module could not be found at /officialperlpath/lib/DynaL +oader.pm line 206.

On the one hand this tells me, that perl actually found and understood /mypath/ccom.pm. On the other hand what really gets me is that said /mypath/auto/ccom/ccom.dll is actually right at that location, but will not be used.

Any meditations on this?

Thanks,
Mike

P.S. Of course when I go for the thing I really want to use, which is use ccom::phonet I get the error that this is not found in the path at all. I'm just thinking of taking it one step at a time at this stage.

Replies are listed 'Best First'.
Re: Tweaking DynaLoader's path without write access to the perl installation
by hv (Prior) on May 30, 2004 at 22:15 UTC

    From the DynaLoader docs:

           @dl_library_path
               The standard/default list of directories in which
               dl_findfile() will search for libraries etc.
    

    The docs go on to describe how the array is initialised, and what you can do with it afterwards.

    Hope this helps,

    Hugo

      Just a simple: perl Makefile.PL LIB=/blah PREFIX=/blah followed by the usual make with a use lib '/blah'; will work fine as the binaries will also be installed into the local dir in the appropriate locations for Dynaloader to find.

      cheers

      tachyon

Re: Tweaking DynaLoader's path without write access to the perl installation
by tachyon (Chancellor) on May 31, 2004 at 00:35 UTC

    All you need to do is specify both a LIB and a PREFIX args to Makefile.PL and your binaries will be installed where you order.

    This is the classic "Hello World!" (in C XS) installed completely into /tmp so that all you need to do is use lib '/tmp' and it will just work....

    C:\Local>perl Makefile.PL LIB=/tmp PREFIX=/tmp Writing Makefile for Local C:\Local>nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. cl -c -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_ST +RICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -D +PERL_MSVCRT_READFIX -O1 -MD -Zi -DNDEBUG -DVERSION=\"0.01\" -DXS_ +VERSION=\"0.01\" -ID:\Perl\lib\CORE Local.c "Running Mkbootstrap for Local ()" [snip rest of blah] C:\Local>nmake test Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. D:\Perl\bin\perl.exe -Iblib\arch -Iblib\lib -ID:\Perl\lib -ID: +\Perl\lib test.pl 1..1 ok 1 Hello, world! C:\Local>nmake install Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. Installing \tmp\MSWin32-x86-multi-thread\auto\Local\Local.bs Installing \tmp\MSWin32-x86-multi-thread\auto\Local\Local.dll Installing \tmp\MSWin32-x86-multi-thread\auto\Local\Local.exp Installing \tmp\MSWin32-x86-multi-thread\auto\Local\Local.lib Installing \tmp\MSWin32-x86-multi-thread\auto\Local\Local.pdb Installing \tmp\Local.pm Installing \tmp\auto\Local\autosplit.ix Writing \tmp\MSWin32-x86-multi-thread\.\auto\Local\.packlist Appending installation info to \tmp\MSWin32-x86-multi-thread\./perlloc +al.pod C:\Local>cd c:\tmp C:\tmp>type test.pl #!/usr/bin/perl use lib '/tmp'; use Local; hello(); C:\tmp>test.pl Hello, world! C:\tmp>

    cheers

    tachyon

Re: Tweaking DynaLoader's path without write access to the perl installation
by El Linko (Beadle) on May 30, 2004 at 23:07 UTC
    It looks like your linker can not find some dlls that are dependencies for /mypath/auto/ccom/ccom.dll. You need to add the directory these dlls are in to you PATH environmental variable. If you are not sure what dlls are causing the problem the windows equivalent for ldd should help.I'm not sure what this is but Dependency Walker seems like a good place to start.

    link@localhost:/tmp$ perl -e'use uB;uB::greet();' Had problems bootstrapping Inline module 'uB_3a3f' Can't load '/tmp/_Inline/lib/auto/uB_3a3f/uB_3a3f.so' for module uB_3a +3f: libstart.so: cannot open shared object file: No such file or dire +ctory at /usr/lib/perl/5.8/DynaLoader.pm line 225. at /usr/local/share/perl/5.8.3/Inline.pm line 500 at uB.pm line 5 BEGIN failed--compilation aborted at uB.pm line 12. Compilation failed in require at -e line 1. BEGIN failed--compilation aborted at -e line 1. link@localhost:/tmp$ ldd _Inline/lib/auto/uB_3a3f/uB_3a3f.so libstart.so => not found libc.so.6 => /lib/libc.so.6 (0x40010000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000) link@localhost:/tmp$ export LD_LIBRARY_PATH=/tmp link@localhost:/tmp$ perl -e'use uB;uB::greet();' Hello, world done link@localhost:/tmp$ ldd _Inline/lib/auto/uB_3a3f/uB_3a3f.so libstart.so => /tmp/libstart.so (0x40004000) libc.so.6 => /lib/libc.so.6 (0x40012000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000) link@localhost:/tmp$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://357671]
Approved by calin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-19 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found