Wasswa Samuel
Wasswa Samuel

Reputation: 2179

unbound module Event error when compiling Ocaml game

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.

Upvotes: 1

Views: 1386

Answers (2)

Jeffrey Scofield
Jeffrey Scofield

Reputation: 66823

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

Upvotes: 1

jrouquie
jrouquie

Reputation: 4425

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.

Upvotes: 1

Related Questions