gpt4 book ai didi

ocaml - 使用 'ocamlfind install' 设置 Ocaml 库,然后在 ocamlbuild 中使用该库

转载 作者:行者123 更新时间:2023-12-01 01:19:07 25 4
gpt4 key购买 nike

我按照说明操作 here用于设置使用 ocamlfind install 在 site-lib 中安装库。我有两个库:一个叫做 logic ,另一个叫做 boolean。在每种情况下,我都在库中安装了 .cmo、.cmx、.cmi 和 .mli 文件,例如:

ocamlfind install boolean META boolean.cmo boolean.cmx boolean.cmi boolean.mli

然后,当我使用 ocamlbuild 构建另一个依赖于逻辑和 bool 值的项目时,收到以下错误消息:
$ocamlbuild -use-ocamlfind test_logic.native -classic-display
...
/home/phil/godi-3.12.1.0/bin/ocamlfind ocamlopt -c -package boolean -package deriving- ocsigen -package deriving-ocsigen.syntax -package logic -package oUnit -package unix -syntax camlp4o -o test_logic.cmx test_logic.ml
/home/phil/godi-3.12.1.0/bin/ocamlfind ocamlopt -linkpkg -linkpkg -package boolean -package deriving-ocsigen -package deriving-ocsigen.syntax -package logic -package oUnit -package unix -syntax camlp4o vhdl.cmx fsm.cmx test_logic.cmx -o test_logic.native
+ /home/phil/godi-3.12.1.0/bin/ocamlfind ocamlopt -linkpkg -linkpkg -package boolean -package deriving-ocsigen -package deriving-ocsigen.syntax -package logic -package oUnit -package unix -syntax camlp4o vhdl.cmx fsm.cmx test_logic.cmx -o test_logic.native
gcc: /home/phil/godi-3.12.1.0/lib/ocaml/site-lib/logic/logic.o: No such file or directory
gcc: /home/phil/godi-3.12.1.0/lib/ocaml/site-lib/boolean/boolean.o: No such file or directory
File "caml_startup", line 1, characters 0-1:
Error: Error during linking
Command exited with code 2.

然后,我将逻辑和 bool 项目中的 .o 文件复制到 site-lib 中的相应区域,然后编译和链接正常。

我想知道为什么需要 .o 文件以及为什么这里涉及 gcc?

这是我的 _tags 文件,以防万一:
<*.ml> or "test_logic.native" or "test_loginc.byte": package(boolean),package(unix),     package(oUnit), package(deriving-ocsigen), package(deriving-ocsigen.syntax), syntax(camlp4o), package(logic)

最佳答案

Section 11.1 of the OCaml Manual :

From the file x.ml, the ocamlopt compiler produces two files: x.o, containing native object code, and x.cmx, containing extra information for linking and optimization of the clients of the unit. The compiled implementation should always be referred to under the name x.cmx (when given a .o or .obj file, ocamlopt assumes that it contains code compiled from C, not from Caml).

关于ocaml - 使用 'ocamlfind install' 设置 Ocaml 库,然后在 ocamlbuild 中使用该库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10310220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com