我嘗試構建一個短的ocaml事件示例。但是當我編譯時,標題中的錯誤出現了。OCaml錯誤:未綁定的模塊事件
問題:unbound module Event error when compiling Ocaml game對我沒有幫助。
該系統的Kubuntu 14.04和我裝ocaml的過資質,所以安裝的軟件包是:
camlp4,ledit,libfindlib-ocaml的,libfindlib-的OCaml開發,liboasis-ocaml的,liboasis-的OCaml開發,libodn -ocaml,libodn-ocaml-dev,libtype-conv-camlp4-dev,oasis,ocaml,ocaml-base,ocaml-base-nox,ocaml-compiler-libs,ocaml-doc,ocaml-findlib,ocaml-interp,ocaml -native編譯器,ocaml的硝
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
我用Google搜索,發現了一些「線程使用小竅門「like:http://caml.inria.fr/pub/docs/manual-ocaml/libthreads.html#c%3Athreads
/usr/lib/ocaml是一個線程文件夾和thread.mli。線程文件夾裏面有這個文件:
-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
我在想什麼?我假設,事件被打包在線程模塊中?
您的編譯器建議對我無效,就像上面提到的一樣。但是您尋找高級工具的提示很有幫助。我可以用「綠洲」和「ocamlbuild」來編譯(讓我們忽略代碼錯誤)...綠洲使用它,我知道。 ...現在它可以工作,但我不知道爲什麼。 Ocamlbuild自動清除依賴關係。 –