OCaml error: Unbound module Event

OCaml error: Unbound module Event

我尝试构建一个简短的 ocaml 事件示例。但是我编译的时候出现了题目中的错误

问题:unbound module Event error when compiling Ocaml game对我没有帮助。

系统是Kubuntu 14.04,我在aptitude上安装了ocaml,所以安装的包是:

camlp4、ledit、libfindlib-ocaml、libfindlib-ocaml-dev、liboasis-ocaml、liboasis-ocaml-dev、libodn-ocaml、libodn-ocaml-dev、libtype-conv-camlp4-dev、绿洲、ocaml , ocaml-base, ocaml-base-nox, ocaml-compiler-libs, ocaml-doc, ocaml-findlib, ocaml-interp, ocaml-native-compilers, ocaml-nox

OCaml 编译器版本为 4.01.0

这是我的简短测试程序。

open Thread;;
open Event;;

let chan = Event.new_channel();;

let a () =
    Printf.printf "A waiting...\n";;
    let sigRX = Event.receive chan  in
        Printf.printf "A received over channel\n";
        let v = Event.sync sigRx  in
            Printf.printf "A running\n";
    Printf.printf "A done!\n";;

let b () = 
    Thread.delay 0.8
    Printf.printf "B sending...\n";;
    let sigTX = Event.send "wake up"  in
        Event.sync sigTX;
        Printf.printf "B done!\n";;


let t_a = Thread.create a ();;
let t_b = Thread.create b ();;

我试图用以下方法编译这个单个文件 (test.ml):

ocamlc -thread unix.cma threads.cma test.ml

响应是:

File "test.ml", line 2, characters 0-10:
Error: Unbound module Event

我用谷歌搜索,发现了一些 "thread-using-tips" 比如:http://caml.inria.fr/pub/docs/manual-ocaml/libthreads.html#c%3Athreads

/usr/lib/ocaml 中有一个 threads 文件夹和一个 thread.mli.在 threads 文件夹中有这个文件:

-rw-r--r-- 1 root root   487 Jan  2  2014 condition.cmi
-rw-r--r-- 1 root root   487 Jan  2  2014 condition.cmx
-rw-r--r-- 1 root root  1203 Jan  2  2014 event.cmi
-rw-r--r-- 1 root root  1867 Jan  2  2014 event.cmx
-rw-r--r-- 1 root root   421 Jan  2  2014 mutex.cmi
-rw-r--r-- 1 root root   407 Jan  2  2014 mutex.cmx
-rw-r--r-- 1 root root  1859 Jan  2  2014 thread.cmi
-rw-r--r-- 1 root root  1308 Jan  2  2014 thread.cmx
-rw-r--r-- 1 root root 62778 Jan  2  2014 threads.a
-rw-r--r-- 1 root root 47047 Jan  2  2014 threads.cma
-rw-r--r-- 1 root root  1258 Jan  2  2014 threads.cmxa
-rw-r--r-- 1 root root  4145 Jan  2  2014 threadUnix.cmi
-rw-r--r-- 1 root root  1515 Jan  2  2014 threadUnix.cmx

我错过了什么?我假设事件是打包在线程模块中的?

这个命令行帮我解决了未绑定模块的问题。

$ ocamlc -I +threads -c test.ml

您的代码中存在错误,但我想您会知道如何修复它们。

这个完整的命令行可能会工作,但由于错误我不能确定:

$ ocamlc -thread -I +threads unix.cma threads.cma test.ml

(有一些用于构建 OCaml 程序的高级工具,您可能希望在某个时候了解它们。)