我尝试使用Mutex模块,例如Mutex.create(),但编译器说Unbound模块Mutex。它需要一些特殊的命名空间吗?感谢
答案 0 :(得分:8)
toplevel :
ocaml -I +threads
# #load "unix.cma";;
# #load "threads.cma";;
# Mutex.create ();;
- : Mutex.t = <abstr>
ocamlc :
ocamlc -thread unix.cma threads.cma src.ml
对于 ocamlopt :
ocamlopt -thread unix.cmxa threads.cmxa src.ml
对于 findlib :
ocamlfind ocamlc -thread -package threads -linkpkg src.ml