Mormanski
Mormanski

Reputation: 23

Compiling a portable Perl and including a CPAN module

I am trying to compile a portable version of perl containing a CPAN module, specifically the YAML module. I intend to be able copy this portable version into my home directory on numerous Redhat Linux machines, add it to my $PATH and use this version instead of the default perl version to run some tests.

I have already managed to compile a portable version of perl and got it working on different machines. However, when I compile the YAML module and install it, it works locally but then fails when I copy it to other machines.

Here's my compilation steps locally for the YAML module

perl Makefile.pl
make test
make install

Which installs the YAML module locally and also works locally when I use the YAML module in a script.

This is the error once I copy perl to another machine and try to use the YAML module...

Can't locate loadable object for module YAML::XS::LibYAML in @INC

even though lib/site_perl/5.10.1/x86_64-linux/YAML/LibYAML.pm exists in my local copy.

Is what I'm attempting to do possible?
If so, where am I going wrong?

Upvotes: 2

Views: 1259

Answers (2)

Galen Howlett
Galen Howlett

Reputation: 695

I used the method described here to successfully do this. I didn't want to bother with an extra library or processing really. I want to use this module in an install script without it being installed to the OS.

So first I installed the module to a local directory on one machine, installing all system requirements necessary yum groupinstall "Development Tools". Then I exported the compiled module with my installer, no longer requiring system changes on subsequent machines.

cd YAML-LibYAML-0.89
perl Makefile.PL PREFIX=../perl
make install

This will create a compiled version of this library, including the C libraries, in a perl directory. You can then copy that perl directory to a new environment and load the library via script. Note that you have to point to the specific lib directory within that directory:

use lib '/path/to/perl/lib64/perl5';
use YAML::XS;

I know this is a very old post but someone might prefer this simpler method.

Upvotes: 0

jira
jira

Reputation: 3944

Possibly you should explore PAR with which you can create an archive of your module dependencies and ship it alongside your application.

Upvotes: 1

Related Questions