[英]using Unix functions in OCaml source
I have a function to get the current time using the unix gettimeofday() in function time.ml . 我有一个函数来使用函数time.ml中的unix gettimeofday()来获取当前时间。 The file accesses the function in the following way: 该文件以下列方式访问该函数:
open Unix; (*declared at the top of the file*)
let get_time () = Unix.gettimeofday ()
The corresponding entry in .mli file is like this: .mli文件中的相应条目如下所示:
val get_time : unit -> float
But during compiling them throws an error: 但在编译期间会抛出错误:
File "_none_", line 1, characters 0-1:
No implementations provided for the following modules:
Unix referenced from time.cmx
I have checked that the following files are present in /lib/ocaml directory: 我已检查/ lib / ocaml目录中是否存在以下文件:
unix.cmi, unix.a unix.cma unix.cmx unix.cmxa unix.cmxs unix.mli
and the path is set correctly set to in .bashrc file. 并且路径设置正确设置为.bashrc文件。
LD_LIBRARY_PATH=~/lib
Other functions like fprintf from Printf module work correctly inspite of being in the same /lib/ocaml directory. 尽管存在于同一个/ lib / ocaml目录中,但来自Printf模块的fprintf等其他函数也能正常工作。
Any ideas what could be wrong? 什么想法可能是错的? Am I doing something wrong or am I missing something? 我做错了什么或者我错过了什么?
You have to compile like this: 你必须像这样编译:
ocamlc unix.cma -c time.mli time.ml (* bytecode *)
or 要么
ocamlopt unix.cmxa -c time.mli time.ml (* native code *)
If you have a properly configured findlib, 如果你有一个正确配置的findlib,
ocamlfind ocamlopt -package Unix -linkpkg time.ml
will save you the trouble of picking the .cma or the .cmxa version. 将为您省去选择.cma或.cmxa版本的麻烦。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.