编译可移植的 Perl 并包含 CPAN 模块
我正在尝试编译包含 CPAN 模块(特别是 YAML 模块)的可移植版本的 perl。我打算能够将此便携式版本复制到许多 Redhat Linux 计算机上的主目录中,将其添加到我的 $PATH 中并使用此版本而不是默认的 perl 版本来运行一些测试。
我已经成功地编译了一个可移植版本的 perl 并让它在不同的机器上运行。但是,当我编译 YAML 模块并安装它时,它可以在本地运行,但当我将其复制到其他计算机时会失败。
以下是 YAML 模块的本地编译步骤,
perl Makefile.pl
make test
make install
它在本地安装 YAML 模块,并且当我在脚本中使用 YAML 模块时也在本地工作。
当我将 perl 复制到另一台计算机并尝试使用 YAML 模块时,这是错误...
Can't locate loadable object for module YAML::XS::LibYAML in @INC
即使 lib/site_perl/5.10.1/x86_64-linux/YAML/LibYAML.pm 存在于我的本地副本中。
我尝试做的事情可能吗?
如果是这样,我哪里出错了?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您应该探索 PAR ,您可以使用它创建模块依赖项的存档并将其与您的应用。
Possibly you should explore PAR with which you can create an archive of your module dependencies and ship it alongside your application.
我使用此处描述的方法成功地做到了这一点。我真的不想为额外的库或处理而烦恼。我想在安装脚本中使用此模块,而不将其安装到操作系统中。
因此,首先我将模块安装到一台计算机上的本地目录,安装所有必要的系统要求
yum groupinstall“开发工具”
。然后,我使用安装程序导出编译后的模块,不再需要在后续计算机上进行系统更改。这将在
perl
目录中创建该库的编译版本,包括 C 库。然后,您可以将该perl
目录复制到新环境并通过脚本加载库。请注意,您必须指向该目录中的特定 lib 目录:我知道这是一篇非常旧的帖子,但有人可能更喜欢这种更简单的方法。
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.This will create a compiled version of this library, including the C libraries, in a
perl
directory. You can then copy thatperl
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:I know this is a very old post but someone might prefer this simpler method.