This tutorial is known to be compatible with ocaml-5.2.0
under Crostini
.
The command ln -s
seem to produce an error, so it's still
possible to use the LN=cp
work-around.
In case you need to re-install the linux
container,
it's possible to install what you compliled in:
$ mkdir -p /mnt/chromeos/MyFiles/Console/usr/local
So the complete set of commands to install ocaml-5.2.0
can be:
$ mkdir -p /mnt/chromeos/MyFiles/Console/usr/local $ sh configure --prefix=/mnt/chromeos/MyFiles/Console/usr/local $ make LN=cp $ make install LN=cp
$ cat /etc/os-release | grep -E '^(NAME=|VERSION_ID=)' NAME="Debian GNU/Linux" VERSION_ID="12"
Running the command ocaml
will produce an error:
$ \ocaml cannot execute: required file not found
But the command ocamlnat
which is an equivalent toplevel
doesn't produce any error.
Never-the-less, it seems it is not installed by default, so you only have to copy it:
$ cp ocamlnat /mnt/chromeos/MyFiles/Console/usr/local/bin/
Or if you prefer to install it with the install
command:
$ /usr/bin/install -c -p -m 755 ocamlnat /mnt/chromeos/MyFiles/Console/usr/local/bin
If you selected a path which is not writable by the user at the
configure
step, you can just add sudo
before the install
command.
Then you can test your ocamlnat
command:
$ ocamlnat OCaml version 5.2.0 - native toplevel #
$ cat /tmp/hello.ml print_endline "hello"
$ ocamlopt.opt -version 5.2.0
$ ocamlopt.opt -o /tmp/hello.opt /tmp/hello.ml $ /tmp/hello.opt hello
Don't forget to define some env-var
's
(environment-variables):
export CAML_LD_LIBRARY_PATH="/mnt/chromeos/MyFiles/Console/usr/local/lib/ocaml/stublibs" export OCAMLPATH="/mnt/chromeos/MyFiles/Console/usr/local/lib/ocaml" export OCAML_TOPLEVEL_PATH="/mnt/chromeos/MyFiles/Console/usr/local/lib/ocaml" export LD_LIBRARY_PATH="/mnt/chromeos/MyFiles/Console/usr/local/lib/ocaml/stublibs:$LD_LIBRARY_PATH" export PATH="/mnt/chromeos/MyFiles/Console/usr/local/bin:$PATH"
If you don't want to define it every-time you will use your
ocaml-5
installation, you can add these env-vars into
your ~/.bashrc
file.
If you don't know yet how to edit a .txt
file
you can read this
vim-tutorial.
Then if you want to use ocamlnat
in stead of
ocaml
in a script, you can replace:
#!/usr/bin/env ocaml
by:
#!/usr/bin/env ocamlnat
At the first line of your script.
I hope you will be happy with your ocaml-5
software!
Happy ocaml
'ing!
2025