是Ocaml的新手,我试图从http://lambda-diode.com/software/ocaml/编译游戏mltetris。我正在使用带有ocaml版本4.00.0的Windows 7但是当我尝试使用下面的命令进行编译时。我收到此错误
C:\Users\WASSWA SAM\ocaml stuff\mltetris>ocamlc -pp camlp4o -o tetris.exe human.
ml game.ml play.ml tetris.ml tetris.mli
File "play.ml", line 21, characters 16-26:
Error: Unbound module Event
事件模块不应该是标准发行版的一部分。我使用这个命令检查了库
C:\Users\WASSWA SAM\ocaml stuff\mltetris>ocamlfind list
bigarray (version: [distributed with Ocaml])
camlp4 (version: [distributed with Ocaml])
camlp4.exceptiontracer (version: [distributed with Ocaml])
camlp4.extend (version: [distributed with Ocaml])
camlp4.foldgenerator (version: [distributed with Ocaml])
camlp4.fulllib (version: [distributed with Ocaml])
camlp4.gramlib (version: [distributed with Ocaml])
camlp4.lib (version: [distributed with Ocaml])
camlp4.listcomprehension (version: [distributed with Ocaml])
camlp4.locationstripper (version: [distributed with Ocaml])
camlp4.macro (version: [distributed with Ocaml])
camlp4.mapgenerator (version: [distributed with Ocaml])
camlp4.metagenerator (version: [distributed with Ocaml])
camlp4.profiler (version: [distributed with Ocaml])
camlp4.quotations (version: [distributed with Ocaml])
camlp4.quotations.o (version: [distributed with Ocaml])
camlp4.quotations.r (version: [distributed with Ocaml])
camlp4.tracer (version: [distributed with Ocaml])
compiler-libs (version: [distributed with Ocaml])
compiler-libs.bytecomp (version: [distributed with Ocaml])
compiler-libs.common (version: [distributed with Ocaml])
compiler-libs.optcomp (version: [distributed with Ocaml])
compiler-libs.toplevel (version: [distributed with Ocaml])
dbm (version: [distributed with Ocaml])
dynlink (version: [distributed with Ocaml])
findlib (version: 1.3.3)
graphics (version: [distributed with Ocaml])
labltk (version: [distributed with Ocaml])
num (version: [distributed with Ocaml])
num-top (version: 1.3.3)
num.core (version: [internal])
ocamlbuild (version: [distributed with Ocaml])
stdlib (version: [distributed with Ocaml])
str (version: [distributed with Ocaml])
threads (version: [distributed with Ocaml])
threads.posix (version: [internal])
unix (version: [distributed with Ocaml])
缺少什么我不知道出了什么问题。
答案 0 :(得分:1)
是的,Event
是标准库的一部分。
在我的机器上,以下命令序列正在运行:
ocamlopt -thread -c human.ml
ocamlopt -thread -c game.ml
ocamlopt -thread -c tetris.ml
ocamlopt -thread -c play.ml
ocamlopt -thread unix.cmxa threads.cmxa graphics.cmxa human.cmx game.cmx tetris.cmx play.cmx -o tetris.opt
而不是手动编译每个文件,这可能适用于这种情况,更长期的方法是使用提供的Makefile,只需发出命令
make
(以上命令实际上是make
运行的内容)。
看来你是在Windows下,在这种情况下,一个选项是安装Cygwin,它提供make
的版本。 Cygwin本身就是一整章,在你开始之前阅读它。
答案 1 :(得分:1)
事件模块似乎是线程工具的一部分。手册说:
使用系统线程的程序必须按如下方式链接:
ocamlc -thread other options unix.cma threads.cma other files
ocamlopt -thread other options unix.cmxa threads.cmxa other files