Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

linking to .so file in non-standard location

by mpeters (Chaplain)
on Mar 06, 2007 at 22:26 UTC ( #603522=perlquestion: print w/replies, xml ) Need Help??
mpeters has asked for the wisdom of the Perl Monks concerning the following question:

I have a script which uses Business::OnlinePayment::PayflowPro which in turn uses a .so file from PayflowPro. It's easy enough for Dynaloader to link to it if it's in the standard lib location, but I want this project to be self-contained, so I'm not putting it in the standard location.

I can fix this if I set $ENV{LD_LIBRARY_PATH} in my shell or the process that spawns this script, but I would like to be able to do it from within my script, but it doesn't work like that.

I assume that there's some DynaLoader incantation I can perform that will work, but I can't quite get my finger on it. Any ideas?

-- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier

Replies are listed 'Best First'.
Re: linking to .so file in non-standard location
by chromatic (Archbishop) on Mar 07, 2007 at 03:51 UTC

    Push the appropriate directory onto @DynaLoader::dl_library_path before using the module which loads the .so file. DynaLoader's documentation is a little unclear about this, but it's there if you know what to look for.

      I tried this
      BEGIN { require DynaLoader; push(@DynaLoader::dl_library_path, '/custom/path'); require Business::OnlinePayment::PayflowPro; }
      Which seems like it ought to work, but doesn't. I still get the same failure: Can't load 'lib/i686-linux/auto/PFProAPI/' for module PFProAPI: cannot open shared object file: No such file or directory at /usr/local/lib/perl5/5.8.8/i686-linux/ line 230. I even verified that DynaLoader can load the module on it's own by calling DynaLoader::dl_findfile(''); which returns the correct path. Any further advice?

      -- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier
Re: linking to .so file in non-standard location
by Sidhekin (Priest) on Mar 06, 2007 at 22:44 UTC

    Ideas? Sure. Good ideas? Not so sure. :)

    To start this thing though: First thing I'd try would be starting my script with this:

    # before loading anything: BEGIN { unless ($ENV{LD_LIBRARY_PATH}) { $ENV{LD_LIBRARY_PATH} = '/the/necessary/path/info'; exec $^X, $0, @ARGV; # add '-T' if necessary } }

    If that works, I'd try without the exec, just to make sure.

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://603522]
Approved by Sidhekin
Front-paged by friedo
[shmem]: LanX can get the logs from cbstream at any time from me.
shmem relocates to the pub over the street. Have a nice time.
[LanX]: well .. not so much interested in reading this article
[LanX]: my 2 cents: AngloZionistic sounds like an antisemtic theory, but to be critical of zionism doesn't mean to be anti-semitic
[shmem]: it hasn't been coined as a *mustread* without authority from the promoter
erix shoots an anti-bubble missile towards LanX
[LanX]: I don't have the time to go into depth of this blog though
[LanX]: anti-bubble missile?
[shmem]: LanX, it's not a matter of time, and you know that.
[shmem]: be precise.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-03-19 21:35 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.