使用外部库编译 ocaml 代码的不同方法
我已经安装了一些库,并正在尝试编译代码。
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.cmi
和 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
生成良好的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的其他问题来看,您似乎有一些示例行需要编译,但在不了解编译选项的情况下只是盲目地行走。
1)你的编译行有
-c
选项。此选项不链接,因此它允许某人编译单个模块并稍后链接它们。这有助于让项目分段构建并分段更新,以加快最终编译速度。因此,-c
选项传递给 ocamlc< /a> 生成cmi
和cmo
字节码编译模块。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 yourcmi
andcmo
, 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.