macosocamlcamlp4

camlp4o is not a bytecode executable file (error on osx)


I had ocaml 3.12, didn't used for a year and now upgraded to 4.03 from git (compiled myself). I saw some comments on the internet that this version does not include camlp4o, mine is from 2010 when i didn't even had ocaml installed. The problem is that i can't compile a program because of it. I went on the harddrive to that file and i don't see anything wrong, but if i try to execute from Terminal i get this

79-116-202-72:ocaml Cristi$ camlp4o
Fatal error: the file '/usr/local/bin/camlp4o' is not a bytecode executable file

The same for the other caml files. Hoping that this will fix my problem how can i update them? I'm using osx. Thanks!


Solution

  • From OCaml 4.02.0 (not released yet!), CamlP4 is dropped from the compiler source code. If you upgrade your OCaml installation from 4.01.0 or prior to 4.02.0 or later, the following thing may happen:

    In this situation, if you type camlp4o, then its bytecode for the older runtime is executed by the newer ocaml bytecode interpreter ocamlrun. Unfortunately, it does not understand the older bytecode. (I guess it is intentional.)

    The fix is to install CamlP4 by your new compiler. The source code is now available at https://github.com/ocaml/camlp4 .

    There are some other possible senarios. For example, if you install OCaml 4.01.0 by hand, then install OPAM using 4.01.0, then change your compiler to 4.02.0 by opam switch. In this case the fix is also to install CamlP4 using the new compiler by opam install camlp4 command.