caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Cobbe <cobbe@ccs.neu.edu>
To: caml-list@yquem.inria.fr
Subject: Trouble with "ocamlbuild main.native"
Date: Tue, 25 Mar 2008 19:17:12 -0400	[thread overview]
Message-ID: <20080325231712.GB86489@perdita.local> (raw)

I'm having some difficulty getting ocamlbuild to produce native binaries
for a project that's spread over multiple directories.  I'm hoping someone
can explain what I'm doing wrong here.

Mac OS X 10.5.2, intel, all updates.
OCaml 3.10.2, ocaml-lib 1.4, ocaml-findlib 1.1.2 (all packaged by Fink)

My project includes several files spread over multiple directories.  The
structure is roughly as follows:

    main.ml
    codeGen.ml
    codeGen.mli
    backEnd.mlpack
    frontEnd.mlpack
    dataRep.mlpack

    backEnd/translate.ml
    backEnd/translate.mli
    backEnd/thunk.ml
    backEnd/thunk.mli

    frontEnd/parser.ml
    frontEnd/parser.mli
    frontEnd/scanner.mll
    frontEnd/scanner.mli

    dataRep/ast.ml
    dataRep/astFold.mli
    dataRep/astFold.ml

and so on.  The directories contain additional modules beyond those I'm
listing here.

The mlpack files contain bare module names.  That is, backEnd.mlpack
contains
    Translate
    Thunk
and so forth.

I do not have a _tags file.  I do have a myocamlbuild.ml file, which is
included below.  This is merely supposed to load in a couple of additional
libraries that were installed via ocaml-findlib.  Unfortunately, this file
is black magic to me -- I copied it off someone's web page and edited only
the list of packages.  I certainly don't understand how it works, and I don't
know whether this is the Right Way to do this.

When I run "ocamlbuild main.cmo" from the top-level directory, everything
builds fine.  I can also run "ocamlbuild main.byte".  I cannot, however,
run "ocamlbuild main.native"; I get the following error message:

    $ ocamlbuild main.native
    + touch dataRep.mli  ; if  ocamlfind ocamlopt -package oUnit,camomile,unix -pack -I dataRep dataRep/srcloc.cmx dataRep/symbol.cmx dataRep/unicodeString.cmx dataRep/ast.cmx dataRep/astFold.cmx -o dataRep.cmx  ; then  rm -f dataRep.mli  ; else  rm -f dataRep.mli  ; exit 1; fi
    File dataRep/srcloc.cmx was not compiled with the `-for-pack DataRep' option
    Command exited with code 1.

Based on the thread at
<http://groups.google.com/group/fa.caml/browse_thread/thread/220d5f88b1176d7c/cfd53734c946ad66?lnk=gst&q=ocamlbuild#cfd53734c946ad66>,
I tried creating a _tags file:

    <frontEnd/**/*.ml>: for-pack(frontEnd)
    <backEnd/**/*.ml>: for-pack(backEnd)
    <dataRep/**/*.ml>: for-pack(dataRep)

But this doesn't work either:

    $ ocamlbuild main.native
    + /sw/bin/ocamldep.opt -for-pack dataRep -modules dataRep/ast.ml > dataRep/ast.ml.depends
    /sw/bin/ocamldep.opt: unknown option `-for-pack'.

It's not a major concern, since I can get by with the bytecode build, but I
would like to know how to build the native binary.  What am I missing?

Many thanks,

Richard

myocamlbuild.ml:

    open Ocamlbuild_plugin;;
    open Command;;

    (* written using a comma separated list *)
    let packages = "oUnit,camomile,unix";;

    let ocamlfind x = S[A"ocamlfind"; x; A"-package"; A packages];;

    dispatch begin function
      | Before_options ->
          Options.ocamlc := ocamlfind& A"ocamlc";
          Options.ocamlopt := ocamlfind& A"ocamlopt";
      | After_rules ->
          flag ["ocaml"; "link"] (A"-linkpkg")
      | _ -> ()
    end;;


             reply	other threads:[~2008-03-25 23:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-25 23:17 Richard Cobbe [this message]
2008-03-26  0:46 ` [Caml-list] " Nicolas Pouillard
2008-03-26  1:37   ` Richard Cobbe

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=20080325231712.GB86489@perdita.local \
    --to=cobbe@ccs.neu.edu \
    --cc=caml-list@yquem.inria.fr \
    /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).