caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Wang <mail@philippewang.info>
To: Walter Cazzola <cazzola@dico.unimi.it>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] separate compilation
Date: Thu, 8 Sep 2011 16:33:11 +0200	[thread overview]
Message-ID: <CAAFfW_rN2eZrehATZJu6PDcqV+irfSOaN0fxV6ROmisegDAQqg@mail.gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1109081552080.2830@surtur.dico.unimi.it>

#stuff are generally for interactive top-level use.
#use and #load definitely are. They can't be compiled.

First, compile interface files:
ocamlc -c a.mli
then compile your ml :
ocamlc -c a.ml
because your ml uses (at least it seems to) information contained in
your mli file.

If your files depend on other files that are in other directories, you
may need to use -I, like in
ocamlc -c -I lib/stuff plop.ml
if you have for instance a dependance on a module contained in lib/stuff.
(Notice that modules on which you depend have to be compiled)

And to use mli information, it has to be compiled (into a cmi file).

Cheers,

-- 
Philippe Wang
   mail@philippewang.info



On Thu, Sep 8, 2011 at 4:26 PM, Walter Cazzola <cazzola@dico.unimi.it> wrote:
> Dear Experts,
> I'm a sort of newbe so be patient with if I ask something too silly
> (I've googled around but I didn't find anything really usefull).
>
> At the moment I'm investigating on how the OCaML module system and the
> separate compilation works.
>
> Nothing original I took the priority queue example from the user manual
> and split it into three files (attached): one with the structure (A.ml)
> one with the signature (A.mli) and one with a silly main (main.ml).
>
> Following the instructions in the manual I have tried to compile each
> file without linking but the only that compiles with success is the file
> with the signature since it doesn't refer to any other file.
>
> When I compile the structure or the main I get this error:
>  >ocamlc -c A.ml
>  File "A.ml", line 17, characters 39-52:
>  Error: Unbound module type CharPQueueAbs
>
> I have tried to put #use or #load in the A.ml and main.ml file but the
> only result is to get a syntax error (e.g., with #use "A.mli" at the
> beggining of A.ml)
>
>  >ocamlc -c A.ml
>  File "A.ml", line 1, characters 0-1:
>  Error: Syntax error
>
> What am I doing wrong? Any help is appreciate, thanks.
>
> Walter
>
> --
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


  reply	other threads:[~2011-09-08 14:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-08 14:26 Walter Cazzola
2011-09-08 14:33 ` Philippe Wang [this message]
2011-09-08 14:40   ` Walter Cazzola
2011-09-08 14:33 ` Esther Baruk
2011-09-08 14:42   ` Walter Cazzola
2011-09-08 15:55     ` AUGER Cedric
2011-09-09  6:50       ` Walter Cazzola
2011-09-09  7:06         ` David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAFfW_rN2eZrehATZJu6PDcqV+irfSOaN0fxV6ROmisegDAQqg@mail.gmail.com \
    --to=mail@philippewang.info \
    --cc=caml-list@inria.fr \
    --cc=cazzola@dico.unimi.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).