From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 3F4A0BC75 for ; Fri, 11 Feb 2005 15:45:07 +0100 (CET) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1BEj6QY029277 for ; Fri, 11 Feb 2005 15:45:06 +0100 Received: by wproxy.gmail.com with SMTP id 71so743967wra for ; Fri, 11 Feb 2005 06:45:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=s12gT1Gct8tkHb/yWepQGxft+BpmaDgTXD/cnFOoolCMw9UWaGfWcor+KQFDn9UdljBp6yp1SZinMSfu1Lz+jNYg6OCj8p0w4nzm1hK5hy3x3xfDHcBQrkKKgVaY/QXpICmxhyhwgfGCE3s696CgBWLdERDvPyveUDcAE77t6I8= Received: by 10.54.41.64 with SMTP id o64mr33390wro; Fri, 11 Feb 2005 06:45:05 -0800 (PST) Received: by 10.54.22.12 with HTTP; Fri, 11 Feb 2005 06:45:05 -0800 (PST) Message-ID: Date: Fri, 11 Feb 2005 09:45:05 -0500 From: John Prevost Reply-To: John Prevost To: =?ISO-8859-1?Q?Juancarlo_A=F1ez?= Subject: Re: [Caml-list] OCAML Newby Question: unbound module? Cc: caml-list@yquem.inria.fr In-Reply-To: <200502101624.j1AGO3qP019814@concorde.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable References: <1107774357-a3361ef8de723e0a521735eb944d0de7@rashitoul.net> <200502101624.j1AGO3qP019814@concorde.inria.fr> X-Miltered: at nez-perce with ID 420CC4F2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; prevost:01 prevost:01 caml-list:01 ocaml:01 newby:01 wrote:01 wrote:01 ocaml:01 mli:01 javac:01 ocamlc:01 mli:01 ocamlc:01 cmo:01 cmo:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.2 X-Spam-Level: On Thu, 10 Feb 2005 12:23:57 -0400, Juancarlo A=F1ez wrote: > Below is the first few lines of code I wrote. Whey I try to run it with > ocaml, I get: >=20 > "File "pattensets.ml", line 1, characters 0-11: > Unbound module Dumper" >=20 > Dumper.mil and dumper.ml are in the same directory. >=20 > 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.