0

I have compiled OCaml from source on my mac (the host), and I have no problem. I have also cross-compiled OCaml on my mac for some target (different from the host) and in this case I have the following issues :

1) I can use directly (on the target) ocamlrun and ocamlyacc as they are "pure" binaries, without problem, as on the host. If I want to use other binaries from $INSTALL/bin ($INSTALL is the install directory of ocaml on the target) like ocamlopt, I have errors telling my that the path of ocamlrun is wrong. Indeed, if I open the ocamlopt binary with and hexadecimal editor, I see that it begins with a #!/not/target/but/host/path/to/ocamlrun where the path is the path to ocamlrun on the host (my mac) on which I configured the cross-build, not the path to its target version... Of course, if I replace this path by the one on the target, no need anymore to do ocamlrun ocamlopt, everything is ok. Same for all others binaries from $INSTALL/bin, ocamlrun and ocamlyacc put aside. (The last two do work directly, as I wrote above.) Is there a way to configure (on host) the ocaml cross-build so that the right path for ocamlrun on the target appears directly at beginning of binaries from $INSTALL/bin ?

2) I cannot compile code without needing to specify the $INSTALL/lib/ocaml dir through the -I flag. Is there a way to force this standard libraries path at the configure ? Or any ocaml "internal" environment variable dealing with it that I could edit to be sure that ocaml will look for libs in $INSTALL/lib/ocaml ? (I am quite pessimistic for an environment variable solution as on the host I only have two environment variables (at printenv) concerning ocaml and no one seems to deal with this kind of stuff, so that I don't see why it would go differently/better on the target...)

objmagic
  • 1,028
  • 1
  • 9
  • 18
Olórin
  • 3,367
  • 2
  • 22
  • 42
  • Do you have a reason to do this by hand instead of opam or even brew's version ocaml? –  Nov 01 '15 at 02:48
  • Yes, and a good one : there's no opam or brew on the target. (As you see in my question, I have an host, my mac, and a target, another os/machine.) So that I am forced to cross-build it, and before cross-building it, I wanted to build it (ocaml) from source to see/observe. (My vanilla ocaml I'm using on the host is not built from source btw, but installed with `opam.) – Olórin Nov 01 '15 at 09:40
  • Have you already looked in [configure](https://github.com/ocaml/ocaml/blob/trunk/configure) and tried the options such as [bindir](https://github.com/ocaml/ocaml/blob/trunk/configure#L175) and libdir? – antron Nov 02 '15 at 17:11

0 Answers0