ocamlopamcamlp4

Install camlp4 version with opam switch


I installed a prior version of OCaml using opam switch create 4.10.2 on MacOS Silicon system: Ventura 13.0.1. I need to install the matching version of camlp4 to be accessible by it. Although I have installed a more recent version of camlp4 my Ocaml switch does not find it.

% opam switch create 4.10.2
...
∗ installed ocaml.4.10.2
Done.
# Run eval $(opam env --switch=4.10.2) to update the current shell environment
% eval $(opam env --switch=4.10.2)

When I run a shell script to make an OCamll package, I get the following error:

sh: camlp4rf: command not found

Cannot find file camlp4/camlp4r.cma.

% ocaml
        OCaml version 4.10.2

% opam --version
2.1.4

% which camlp4        
camlp4 not found

% camlp5 -version
8.00.04

% camlp4 -version
zsh: command not found: camlp4

.../.opam/4.10.2/bin contains many OCaml files but no camlpm

.../.opam/4.10.2/.opam-switch also conatins many OCaml files but not camlp4

In contrast, the not found files exist in the opam default version:

locate camlp4rf
.../.opam/default/bin/camlp4rf
.../.opam/default/bin/camlp4rf.opt
.../.opam/default/lib/ocaml/camlp4/camlp4rf.cma

How do I get them found and recognized by the switch? Or how do I install the camlp4 with opam switch?

I tried running the package with OCaml 5 and camlp5, and with OCaml 4.14.1 neither of which work since the package requires commands and files no longer a part of these later versions.


Solution

  • You can install camlp4 within your switch with

    $ opam install camlp4
    

    you may want to check that your shell environment is pointing towards the right switch with

    $ opam switch
    

    before however.