[
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: | 2008-03-25 (23:17) |
From: | Richard Cobbe <cobbe@c...> |
Subject: | Trouble with "ocamlbuild main.native" |
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;;