gpt4 book ai didi

unix - 在 OCaml 源代码中使用 Unix 函数

转载 作者:行者123 更新时间:2023-12-04 22:49:30 25 4
gpt4 key购买 nike

我有一个使用函数 time.ml 中的 unix gettimeofday() 获取当前时间的函数。该文件通过以下方式访问该函数:

open Unix; (*declared at the top of the file*)

let get_time () = Unix.gettimeofday ()

.mli 文件中对应的条目是这样的:
val get_time : unit -> float

但是在编译它们时会抛出一个错误:
File "_none_", line 1, characters 0-1:
No implementations provided for the following modules:
Unix referenced from time.cmx

我已检查/lib/ocaml 目录中是否存在以下文件:
unix.cmi, unix.a unix.cma unix.cmx unix.cmxa unix.cmxs unix.mli 

并且在 .bashrc 文件中正确设置了路径。
LD_LIBRARY_PATH=~/lib

尽管位于相同的/lib/ocaml 目录中,但来自 Printf 模块的 fprintf 等其他功能也可以正常工作。

有什么想法可能是错的吗?我做错了什么还是我错过了什么?

最佳答案

你必须像这样编译:

ocamlc unix.cma -c time.mli time.ml (* bytecode *)

或者
ocamlopt unix.cmxa -c time.mli time.ml  (* native code *)

关于unix - 在 OCaml 源代码中使用 Unix 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10929228/

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