multithreading - OCaml 错误 : Unbound module Event

标签 multithreading events module compiler-errors ocaml

我尝试构建一个简短的 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

我搜索了一下,发现了一些“线程使用提示”,例如:http://caml.inria.fr/pub/docs/manual-ocaml/libthreads.html#c%3Athreads

/usr/lib/ocaml 线程 文件夹和 线程.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

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

最佳答案

这个命令行可以帮助我解决未绑定(bind)的模块问题。

$ ocamlc -I +threads -c test.ml

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

这个完整的命令行可能会起作用,但由于错误,我无法确定:
$ ocamlc -thread -I +threads unix.cma threads.cma test.ml

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

关于multithreading - OCaml 错误 : Unbound module Event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30003849/

相关文章:

python - 与 import python 有点混淆

javascript - Three.js 的粒子系统作为 npm 包

c# - 使用 Task.WaitAny() 获取完成的任务 ID

Java 同步

perl - AnyEvent::Fork 如何等待 child

c++ - 具有不同 C/C++ 运行时库的 exe 和 dll 之间的接口(interface)

java - 文件未正确读取 - 数据 I/O 流

c# - 如何让一个类的多个实例(在不同的线程中)监听同一个事件?

c# - 检测没有子项的 mdiContainer 上的双击(c# winforms)

java - 如何在 Android 中将多线程用于事件处理函数 (SensorListeners)