Browse thread
Socket and Threads on windows
-
Julien Boulnois
-
Olivier_Pérès
-
Julien Boulnois
-
Juancarlo_Añez
- John Prevost
-
Juancarlo_Añez
-
Julien Boulnois
-
Olivier_Pérès
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-02-11 (14:45) |
From: | John Prevost <j.prevost@g...> |
Subject: | Re: [Caml-list] OCAML Newby Question: unbound module? |
On Thu, 10 Feb 2005 12:23:57 -0400, Juancarlo Añez <juanca@suigeneris.org> wrote: > Below is the first few lines of code I wrote. Whey I try to run it with > ocaml, I get: > > "File "pattensets.ml", line 1, characters 0-11: > Unbound module Dumper" > > Dumper.mil and dumper.ml are in the same directory. > > What am I doing wrong? First, the filenames should be dumper.mli and dumper.ml (I expect these are correct, but just checking.) Second, unlike with javac, you must tell ocamlc which source files to compile and/or link, and in what order. In this case: # produce the .cmi file from the .mli file ocamlc -c dumper.mli # produce the .cmo file from the .ml file ocamlc -c dumper.ml # produce the .cmo file from the .ml file ocamlc -c program.ml # produce the executable from the .cmo files ocamlc -o program dumper.cmo program.cmo Or in short: ocamlc -o program dumper.mli dumper.ml program.ml Note that ocamlopt is pretty much the same, but the extensions of .cmo change to .cmx. The reason that you need to specify the order in which files are listed for linking is that this determines which modules are in scope at any point, and also determines an order for the initialization of each module. Finally, if you are trying to run in the ocaml toplevel, you want to do the steps above to produce the .cmo file for dumper, then: #load "dumper.cmo";; in the toplevel will cause the compiled code for dumper to be loaded into memory. (The compiled interface, dumper.cmi, will be found and loaded automatically when you first refer to the Dumper module, but until you load the .cmo file, the values from the module will not be available.) You might want to take a look at the ocaml beginner's list: http://groups.yahoo.com/group/ocaml_beginners or at chapter 8 of the manual (Batch Compilation (ocamlc)) if you have more problems like this. John.