I have a case in which I build a native executable using jbuilder
, and the ocamlopt.opt
command line has two .cmxa files in the wrong order. I don’t understand everything going on in the command line; what I mean is that I get an error from the command line that jbuilder
constructs, but when I reverse the cmxa files and run the ocamlopt.opt
with the cmxa files reversed, it compiles the executable.
Or maybe this is not a jbuilder issue, but has to do with some other tool?
jbuild file:
(jbuild_version 1)
(executables
((names (test))
(public_names (test))
(package yo)
(libraries (bigarray hdf5_caml))
(modes (native))
))
Command line that jbuilder
(and friends) constructs, along with the error:
(cd _build/default && /Users/marshall/.opam/4.05.0+flambda/bin/ocamlopt.opt -w -40 -g -o src/yo/test.exe -I /Users/marshall/.opam/4.05.0+flambda/lib/hdf5_caml -I /Users/marshall/.opam/4.05.0+flambda/lib/hdf5_raw -I /Users/marshall/.opam/4.05.0+flambda/lib/ocaml /Users/marshall/.opam/4.05.0+flambda/lib/ocaml/unix.cmxa /Users/marshall/.opam/4.05.0+flambda/lib/hdf5_raw/hdf5_raw.cmxa /Users/marshall/.opam/4.05.0+flambda/lib/ocaml/bigarray.cmxa /Users/marshall/.opam/4.05.0+flambda/lib/hdf5_caml/hdf5_caml.cmxa src/yo/test.cmx)
File "_none_", line 1:
Error: No implementations provided for the following modules:
Bigarray referenced from /Users/marshall/.opam/4.05.0+flambda/lib/hdf5_raw/hdf5_raw.cmxa(Hdf5_raw)
Here’s the ocamlopt.opt
command line formatted for easy reading:
~/.opam/4.05.0+flambda/bin/ocamlopt.opt -w -40 -g -o src/yo/test.exe
-I ~/.opam/4.05.0+flambda/lib/hdf5_caml
-I ~/.opam/4.05.0+flambda/lib/hdf5_raw
-I ~/.opam/4.05.0+flambda/lib/ocaml
~/.opam/4.05.0+flambda/lib/ocaml/unix.cmxa
~/.opam/4.05.0+flambda/lib/hdf5_raw/hdf5_raw.cmxa
~/.opam/4.05.0+flambda/lib/ocaml/bigarray.cmxa
~/.opam/4.05.0+flambda/lib/hdf5_caml/hdf5_caml.cmxa
src/yo/test.cmx
If I reverse these two arguments
~/.opam/4.05.0+flambda/lib/hdf5_raw/hdf5_raw.cmxa
~/.opam/4.05.0+flambda/lib/ocaml/bigarray.cmxa
the command succeeds. I gather that the Bigarray
lib needs to be first so that Hdf5_raw
can reference it. (Hdf5_raw
does in fact use Bigarray
.)
Any idea about what’s going wrong when the command line is constructed?