1

我是 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])

缺少什么我不知道出了什么问题。

4

2 回答 2

1

事件模块似乎是线程工具的一部分。手册是这样说的:

使用系统线程的程序必须按如下方式链接:

   ocamlc -thread other options unix.cma threads.cma other files  
   ocamlopt -thread other options unix.cmxa threads.cmxa other files
于 2012-11-08T23:11:58.840 回答
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 本身就是一个完整的章节,在开始之前阅读它。

于 2012-11-08T23:10:03.860 回答