unbound module Event error when compiling Ocaml game

别说谁变了你拦得住时间么 提交于 2019-12-11 06:48:20

问题


Am new to Ocaml and i was trying to compile the game mltetris from http://lambda-diode.com/software/ocaml/. I am using windows 7 with ocaml version 4.00.0 however when i try to compile using the command below. I get this error

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

Isn't the Event Module supposed to be part of the standard distribution. I checked the libraries using this command

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

What's missing I don't know what's wrong.


回答1:


Yes, Event is part of the standard library.

On my machine, the following sequence of commands is working:

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



Instead of manually compiling every file, which may work in this case, a more long term approach is to use the provided Makefile, by just issuing the command

make

(The above commands are actually what make runs). It seems you're under Windows, in which case an option is to install Cygwin, wich provides a version of make. Cygwin is a whole chapter in itself, read about it before you start.




回答2:


The events module appears to be part of the threads facility. The manual says this:

Programs that use system threads must be linked as follows:

   ocamlc -thread other options unix.cma threads.cma other files  
   ocamlopt -thread other options unix.cmxa threads.cmxa other files


来源:https://stackoverflow.com/questions/13299235/unbound-module-event-error-when-compiling-ocaml-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!