Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks like maybe your OCaml compiler is producing 32-bit executables. One way to tell is to say:</p> <pre><code>$ ocamlopt -config </code></pre> <p>If you see <code>architecture i386</code>, it's a 32-bit compiler. If you see <code>architecture amd64</code>, it's a 64-bit compiler. At any rate, these are the two different values I see on my Macbook Pro.</p> <p><strong>Edit</strong></p> <p>The <code>Makefile</code> you give doesn't really describe what you're trying to do. It just defines names for some language processors. The real <code>Makefile</code> is possibly elsewhere.</p> <p>Since the <code>Makefile</code> doesn't actually say anything about what you're doing, I realized that I don't see any evidence that you're linking OCaml and C++ (or C) together. The first line of output doesn't show anything except what looks like OCaml files. Furthermore, they're named <code>xyz.cmo</code>, which are <em>bytecode</em> OCaml files. That is, they're not 32-bit <em>or</em> 64-bit (native) files.</p> <p>Do you have some C++ and some OCaml components that need to be linked together, or is your project pure OCaml? If it's pure OCaml, I'd say the problem is all in the <code>Makefile</code>. You shouldn't have to worry about the architecture if you just want to run OCaml code.</p> <p>If there's some C++ or C, then you need to compile it with <code>-arch i386</code> (to get 32-bit objects) and then link everything together with a linker (<code>ld</code>) that knows it's producing a 32-bit target. (Or, as Fabrice Le Fessant says, you could install a 64-bit OCaml compler.)</p> <p>A possible suggestion is to create a tiny OCaml file and just see if you can compile and run it.</p> <p>Using the bytecode compiler, it looks like this:</p> <pre><code>$ uname -rs Darwin 10.8.0 $ cat tiny.ml Printf.printf "hello world\n" $ ocamlc -o tiny tiny.ml $ file tiny.cmo tiny.cmo: Objective caml object file (.cmo) (Version 006). $ file tiny tiny: a /sw/bin/ocamlrun script text executable $ tiny hello world </code></pre> <p>Using a native 32-bit compiler, it looks like this:</p> <pre><code>$ ocamlopt -o tiny tiny.ml $ file tiny.cmx tiny.cmx: Objective caml native object file (.cmx) (Version 011). $ file tiny.o tiny.o: Mach-O object i386 $ file tiny tiny: Mach-O executable i386 $ tiny hello world </code></pre> <p><strong>Edit 2</strong></p> <p>Your second makefile still doesn't show what you're trying to do, specifically. It just defines some make rules for compiling and linking different types of executables. However, since you say your project is all OCaml, then I'd say the entire problem is in this Makefile.</p> <p>The problem appears to be that this Makefile specifies which C compiler and libraries the OCaml compiler should use as its back-end, using the <code>-cc</code> and <code>-cclib</code> options. On most systems, it will work OK to just specify the standard C compiler as the back-end for OCaml. On Mac OS X, there are 32-bit/64-bit architectural complications. Since you can compile OCaml successfully without this Makefile, I'd suggest that the OCaml compiler already knows how to compile and link OCaml programs. So you might try just removing the <code>-cc</code> and <code>-cclib</code> options from the Makefile.</p> <p>To do this: In all three sections under <code>OCAML_EXE</code> remove the third line entirely (the line with <code>-cc</code> and <code>-cclib</code>), and <em>remove the trailing backslash on the previous line</em>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload