caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Trouble with "ocamlbuild main.native"
@ 2008-03-25 23:17 Richard Cobbe
  2008-03-26  0:46 ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Cobbe @ 2008-03-25 23:17 UTC (permalink / raw)
  To: caml-list

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;;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Trouble with "ocamlbuild main.native"
  2008-03-25 23:17 Trouble with "ocamlbuild main.native" Richard Cobbe
@ 2008-03-26  0:46 ` Nicolas Pouillard
  2008-03-26  1:37   ` Richard Cobbe
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Pouillard @ 2008-03-26  0:46 UTC (permalink / raw)
  To: Richard Cobbe; +Cc: caml-list caml-list

[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

Excerpts from Richard Cobbe's message of Wed Mar 26 00:17:12 +0100 2008:
> 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.

You've hitted the -for-pack oddify :)

[...]

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

Almost there... that's .cmx instead of .ml

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

Best regards,

-- 
Nicolas Pouillard aka Ertai

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 240 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Trouble with "ocamlbuild main.native"
  2008-03-26  0:46 ` [Caml-list] " Nicolas Pouillard
@ 2008-03-26  1:37   ` Richard Cobbe
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Cobbe @ 2008-03-26  1:37 UTC (permalink / raw)
  To: caml-list caml-list

On Wed, Mar 26, 2008 at 01:46:35AM +0100, Nicolas Pouillard wrote:
> Excerpts from Richard Cobbe's message of Wed Mar 26 00:17:12 +0100 2008:
> > 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.
>
> You've hitted the -for-pack oddify :)
>
> [...]
>
> >     <frontEnd/**/*.ml>: for-pack(frontEnd)
> >     <backEnd/**/*.ml>: for-pack(backEnd)
> >     <dataRep/**/*.ml>: for-pack(dataRep)
>
> Almost there... that's .cmx instead of .ml
>
>      <frontEnd/**/*.cmx>: for-pack(frontEnd)
>      <backEnd/**/*.cmx>: for-pack(backEnd)
>      <dataRep/**/*.cmx>: for-pack(dataRep)

Ah!  That was it!

Compiles perfectly now.  Thanks so much!

Richard


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-26  1:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-25 23:17 Trouble with "ocamlbuild main.native" Richard Cobbe
2008-03-26  0:46 ` [Caml-list] " Nicolas Pouillard
2008-03-26  1:37   ` Richard Cobbe

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).