views:

697

answers:

3

I was using PAR::Packer to package my Perl application on Cygwin and then running it on HPUX.

A simple hello world works well, e.g.:

pp -p hello.pl

That results in a.par and then on HPUX:

parl a.par

It works great.

However when package a bigger application with many dependencies with -B bundle switch, no such luck, instead I get the error:

 Can't locate loadable object for module Socket in @INC

Any ideas, maybe some problem with Windows/unix networking? Any fixes?

+5  A: 

You're hitting this because Socket loads a shared library, and that's not portable across platforms (that is, the Socket shared lib on Windows won't work on Linux won't work on HPUX).

You could try two things:

  1. Identify all the places you need shared libs, and have a native install of them on your target platform. You may also need to exclude those modules from your PAR archive.
  2. Switch to pure-Perl implementations (which are (more) portable). If you're not a whiz at Perl, C, and your target platform, and a pure-Perl version is not already available, you may be out of luck with this.
Andrew Barnett
Thanks, the native code issue makes sense, there probably aren't that many modules except for this Socket one that include native code, so I will try the first approach. Is there a simple way to scan the dependencies and print out ones that include native code?
Ville M
I can't think of a particularly easy way to scan the dependencies. You could put a coderef into @INC and try to intercept Dynaloader calls, but you're probably better off with something like Module::Info (which, if I recall, is required for PAR already).
Andrew Barnett
See my update above, still getting an error for some reason, is there a switch I need to add to parl at runtime on HPUX in order to have it also looks in it's default library path?
Ville M
+2  A: 

The advantage of installing an actual perl on your HPUX is that your cygwin app can then run on the hpux perl. PAR packages aren't normally going to work between any two platforms. In my mind, it's not really any different than producing the hello.exe on cygwin and trying to run it on HPUX.

jettero
+1  A: 

Perl blixtor's advice from comments I am moving the "edit updates" I had in the question to answer my own question here:

Most of the credit here goes to Andrew Barnett, the 2 key issues were the

  1. native C code library
  2. the perl LIB paths

Here were the steps I followed to get the cygwin created par to run on HPUX, I believe steps should be about same on any unix:

Followed Andrew's advice and removed IO::Socket with the pp -X IO::Socket switch, but then running the resulting parl on unix I get slightly modified but still related error:

Can't locate Socket.pm in @INC (@INC contains: CODE(0x406ab018) CODE(0x4055c880) CODE(0x40563978)) at Net/Config.pm line 11

even though running "perl -MCPAN -e shell" on the unix showed Socket should be installed and up to date:

cpan[2]> install IO::Socket
IO::Socket is up to date (1.30_01).

So in addition to excluding Socket with the -X switch abobe, I also had to create a wrapper script on HPUX with just this 1 line in in, wrapper.pl:

use PAR { file => 'bdiff.par', run => 'bdiff.pl' };

then to run this I didn't use parl, instead I would just call it with perl and I had to supply the entire paths to the default lib paths with the -I switch, like this:

perl -I/lib/perl5/lib/5.10.0/PA-RISC2.0 -I/lib/lib/site_perl wrapper.pl allparameters

for some reason when using parl it seems the the default lib paths get excluded, hence the full paths above.

Ville M