手动安装 Perl 模块

发布于 2024-12-06 11:09:50 字数 804 浏览 0 评论 0原文

我已经下载了模块 Digest::SHA1 并将其提取到目录 (../Digest-SHA1-2.13/) ,然后将所有 SHA1.* 文件复制到 (../Digest-SHA1 -2.13/Digest)

,在 perl 脚本中,我做了: use Digest::SHA1; 像这样启动脚本:

perl -I ../Digest-SHA1-2.13/Digest perlscriptname.pl

我收到此错误:

Can't locate loadable object for module Digest::SHA1 in @INC

我假设它与共享库(*.so)有关?,我不知道如何从这里继续。

我可以使用 CPAN (-MCPAN) 模块直接安装它,因为我在该服务器上没有执行此操作的权限,并且只能在本地安装(应用程序运行的位置)。 我的最终目标是使用 Algorithm::CouponCode ,它依赖于 Digest::SHA1

奇怪的是,我有 Digest::SHA1 > 已安装(perl -MDigest::SHA1 -e 'print $Digest::SHA1::VERSION' 显示版本 2.11),仍然Algorithm::CouponCode (其安装方式与我使用 Digest::SHA1 的方式相同)抱怨它可以在 @INC 中找到它,

谢谢!

I have downloaded the module Digest::SHA1 and extracted it to a directory (../Digest-SHA1-2.13/) , then copied all the SHA1.* files into (../Digest-SHA1-2.13/Digest)

and in the perl script, I did : use Digest::SHA1;
launching the script like this:

perl -I ../Digest-SHA1-2.13/Digest perlscriptname.pl

I get this error:

Can't locate loadable object for module Digest::SHA1 in @INC

I assume it has something to do with a shared library (*.so)?, I have no idea how to continue from here.

I can install it directly using CPAN (-MCPAN) module, as I dont have permissions on that server to do that, and can install only locally (where the application is running).
My final goal is to use Algorithm::CouponCode which is dependent on Digest::SHA1

The weird part is, that I have Digest::SHA1 installed (perl -MDigest::SHA1 -e 'print $Digest::SHA1::VERSION' shows version 2.11), still Algorithm::CouponCode (which is installed the same way I did with Digest::SHA1) complains it can find it in @INC

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

转角预定愛 2024-12-13 11:09:50

使用此方法手动安装 perl 模块:

tar zxf Digest-SHA1-2.13.tar.gz
cd Digest-SHA1-2.13
perl Makefile.PL
make
make test
make install

请注意,某些发行版将具有 Build.PL 文件,而不是 Makefile.PL。在这种情况下,请使用以下配方:(

tar zxf ...
cd ...
perl Build.PL
./Build
./Build test
./Build install

您可能只需运行 make install./Build install 即可。)

如果您需要更改安装目录,则use:

perl Makefile.PL INSTALL_BASE=...

perl Build.PL --install_base ...

取决于模块的种类。

有关详细信息,请参阅 ExtUtils::MakeMaker::FAQ 的 perldoc和 Module::Build

Use this recipe for manually installing perl modules:

tar zxf Digest-SHA1-2.13.tar.gz
cd Digest-SHA1-2.13
perl Makefile.PL
make
make test
make install

Note that some distributions will have a Build.PL file instead of Makefile.PL. In that case use this recipe:

tar zxf ...
cd ...
perl Build.PL
./Build
./Build test
./Build install

(You may be able to get by with just running make install and ./Build install.)

If you need to alter the installation dir then use:

perl Makefile.PL INSTALL_BASE=...

or

perl Build.PL --install_base ...

depending on the kind of module.

For more info see the perldoc for ExtUtils::MakeMaker::FAQ and Module::Build

左岸枫 2024-12-13 11:09:50

Perl 模块有两种:pure-Perl 和 XS。 Pure-Perl 模块完全用 Perl 编写,通常只需将 .pm 文件复制到适当的目录即可安装。 XS 模块是用 Perl 和 C 编写的(XS 由 ExtUtils:: 处理为 C 代码ParseXS 模块)并需要 C 编译器来安装它们。

正如 dsolimano 所说,当您没有 root 访问权限时,为系统 Perl 安装 Perl 模块的最简单方法是使用 本地::lib。 (你可以做 local::lib 自己做的同样的事情,但为什么要麻烦呢?)

为什么 Digest::SHA1 单独工作但当你使用Algorithm::CouponCode的原因是系统Perl已经安装了2.11版本的Digest::SHA1。当您使用 -I ../Digest-SHA1-2.13/Digest 时,use Digest::SHA1 将从 ../Digest-SHA1-2.13 中获取 Perl 代码/Digest,但是从 XS 代码构建的共享库不在相应的位置。

There are two kinds of Perl module: pure-Perl and XS. Pure-Perl modules are written entirely in Perl, and can usually be installed just by copying the .pm files to an appropriate directory. XS modules are written in both Perl and C (XS is processed into C code by the ExtUtils::ParseXS module) and require a C compiler to install them.

As dsolimano said, the easiest way to install Perl modules for the system Perl when you don't have root access is to use local::lib. (You could do the same things that local::lib does yourself, but why bother?)

The reason why Digest::SHA1 works by itself but not when you're using Algorithm::CouponCode is that the system Perl already has version 2.11 of Digest::SHA1 installed. When you use -I ../Digest-SHA1-2.13/Digest, then use Digest::SHA1 picks up the Perl code from ../Digest-SHA1-2.13/Digest, but the shared library that would be built from the XS code is not in the corresponding location.

鸵鸟症 2024-12-13 11:09:50

有什么原因不能使用 local::lib 吗?

为带有 PERL5LIB 的 perl 模块创建并使用本地 lib/

它基本上是一个帮助您使用私有(非系统范围)目录作为 Perl 库目录的工具。

设置完成后,您可以运行类似的命令

perl -MCPAN -Mlocal::lib -e 'CPAN::install(Algorithm::CouponCode)'

,然后您的脚本将使用本地安装的 Algorithm::CouponCode) 副本

Any reason why you can't use local::lib?

create and use a local lib/ for perl modules with PERL5LIB

It is basically a tool to help you use a private (non-systemwide) directory as your Perl library directory.

After setting it up, you could run a command like

perl -MCPAN -Mlocal::lib -e 'CPAN::install(Algorithm::CouponCode)'

and then your script would use your locally installed copy of Algorithm::CouponCode).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文