【问题标题】:raku, library was not found乐,找不到图书馆
【发布时间】:2021-05-29 20:08:24
【问题描述】:

我试图在Raku 中执行此程序,但出现以下错误: 我应该如何为raku 提供perl 库;在哪里复制什么?

use Math::BigInt;
$i = Math::BigInt->new($string);
use Math::BigInt ':constant';
print 10**121900;

在

中找不到Math::BigInt

编辑

zef安装后运行失败:

无法统计文件:没有这样的文件或目录

编辑

无法统计文件:没有这样的文件或目录

【问题讨论】:

  • 第一个问题:为什么要使用Math::BigInt?默认情况下,Raku 中的整数是 bigint。只需执行 print 10**121900 会给你一个 1 后跟 121900 零。
  • 第二个问题:为了能够使用 Raku 的 Perl 模块,您必须首先安装 Inline::Perl5 模块:zef install Inline::Perl5。之后,您可以使用带有from<Perl5> 副词的模块。在您的示例中:use Math::BigInt:from<Perl5>.
  • 您的第一个答案有帮助,它确实有效。对于您的第二条评论,我使用Cygwin,它不知道像zef 这样的东西。你能给我一个下载链接InLine::Perl5吗?
  • 那么最好先下载zef(git clone https://github.com/ugexe/zef.git 并按照自述文件),然后执行zef install Inline::Perl5 :-)
  • @user2925716 在安装 Rakudo 之前,您访问了哪个链接?

标签: perl shared-libraries raku


【解决方案1】:

Math::BigInt 是一个 Perl 模块

  1. Inline::Perl 需要安装在 Raku 中
  2. Math::BigInt 需要安装在 Perl 中
  3. 您需要告诉 Raku 它是一个 Perl 模块,而不是默认的 Raku 模块
use Inline::Perl5;
use Math::BigInt:from<Perl5>;

my $string = "121900";
my $i = Math::BigInt->new($string);

say 10**$i;

(未测试,因为我不在电脑旁)

当然这没什么意义,因为 Raku 已经支持大整数了。

say 10**121900;

【讨论】:

  • 通过Inline::Perl5 桥加载Math::BigInt 似乎存在问题。
猜你喜欢
  • 2013-10-15
  • 2014-11-12
  • 2013-12-16
  • 2021-02-15
  • 2021-07-13
  • 2022-09-23
  • 2015-06-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多