使用外部库编译 ocaml 代码的不同方法

发布于 2024-12-05 13:13:05 字数 1361 浏览 1 评论 0原文

我已经安装了一些库,并正在尝试编译代码。

1) ocamlc -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -c mlexample2.ml< /code> 生成良好的 mlexample2.cmimlexample2.cmo

2) ocamlopt -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -o mlexample2.opt 生成良好的 mlexample2.cmx

3) 但是,如果我遵循 此页面: ocamlopt -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -o mlexample2.opt \ bigarray。 cmxa gmp.cmxa apron.cmxa boxMPFR.cmxa polkaMPQ.cmxa mlexample2.ml 返回文件“mlexample2.ml”,第 1 行,字符 0-1:错误:找不到文件 bigarray.cmxa,其中 usr/lib 代表 $APRON/lib在文档中。但 big.array.cmxa 实际上位于 /usr/lib/ocaml/bigarray.cmxa 中。顺便说一句,此命令确实生成 .cmi.cmx.o

所以我的问题是:

我如何从 1) 的 .cmi.cmo 取得进展?

我如何从 2) 的 .cmx 取得进展,

如何处理 3) 中的错误

?任何人都可以帮忙吗?非常感谢!

编辑1: 2)应该是:ocamlopt -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml /3.11.2/gmp -c mlexample2.ml 生成 .cmi.cmx.o

I have installed some libraries, and am trying to compile a code.

1) ocamlc -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -c mlexample2.ml generates well mlexample2.cmi and mlexample2.cmo

2) ocamlopt -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -o mlexample2.opt generates well mlexample2.cmx

3) However, If I follow the native-code compilation of this page:
ocamlopt -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -o mlexample2.opt \ bigarray.cmxa gmp.cmxa apron.cmxa boxMPFR.cmxa polkaMPQ.cmxa mlexample2.ml returns File "mlexample2.ml", line 1, characters 0-1: Error: Cannot find file bigarray.cmxa, where usr/lib represents $APRON/lib in the doc. But big.array.cmxa is effectively in /usr/lib/ocaml/bigarray.cmxa. By the way, this command does generate .cmi, .cmx and .o.

So my questions are:

How could I progress from .cmi and .cmo of 1)?

How could I progress from .cmx of 2)

What can I do with the error in 3)

Could anyone help? Thank you very much!

Edit1: 2) should be: ocamlopt -I /usr/lib -I /usr/local/lib/ocaml/3.11.2/apron -I /usr/local/lib/ocaml/3.11.2/gmp -c mlexample2.ml generates .cmi, .cmx and .o.

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

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

发布评论

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

评论(1

甜点 2024-12-12 13:13:05

从您的其他问题来看,您似乎有一些示例行需要编译,但在不了解编译选项的情况下只是盲目地行走。

1)你的编译行有 -c 选项。此选项不链接,因此它允许某人编译单个模块并稍后链接它们。这有助于让项目分段构建并分段更新,以加快最终编译速度。因此, -c 选项传递给 ocamlc< /a> 生成 cmicmo 字节码编译模块。

2)您在示例编译行中缺少一些内容——它没有提到任何有关生成附加文件的内容。我假设您还使用 -c 选项。这是因为 .cmx 也是一个已编译的模块,但通过 ocamlopt

3)这应该是一个非常明显的需要修复的编译错误。 bigarry.cmxa 位于您包含的目录中的哪个位置?没有一个。您自己说过它位于 /usr/lib/ocaml/ 中,您没有包含该目录!目录不会递归搜索,并且您之前在其他问题中已经经历过这种情况。

我强烈建议你阅读有关编译的手册。您正在阅读的这份文档在如何编译方面是正确的,但是您已经以不同的方式设置了环境,并且在您掌握这些命令实际执行的操作之前,辨别差异将是令人沮丧的。

From your other questions, it seems like you got some sample lines to compile and just blindly walking though without understanding the compile options.

1) You're compile line has the -c option. This option does not link, thus it allows someone to compile an individual module and link them later. This is helpful to allow the project to be built in pieces and updated in pieces for quicker final compilation. So, the -c option passed to ocamlc produces your cmi and cmo, byte-code complied module.

2) You are missing something here in your sample compile line --it doesn't mention anything regarding to produce an additional file. I'm going to assume that you also use the -c option. This is because a .cmx is also a compiled module, but natively compiled via ocamlopt.

3) This should be a pretty obvious compilation error to fix. Where in your included directories does bigarry.cmxa reside? None of them. You've said it yourself that it is in /usr/lib/ocaml/, a directory you did not include! The directories do not search recursively, and you've experienced that before in other questions.

I strongly suggest you read the manual on compilation. This documentation you're wading through is correct in how to compile, but you've set your environment up in a different way and discerning the differences is going to be frustrating until you get a handle on what those commands are actually doing.

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