How to install a specific ocaml compiler version with opam

How to install a specific version of ocaml compiler (and compatible packages) using opam (or another box)?

I quickly looked through the opam documentation, but I did not find the relevant information.

I need an ocaml compiler (preferably my own code compiler) to create unison, file synchronization software. I need to build a unison on two machines using the same ocaml version, or else the unison emits an error and cancels its duty (yiiii!).

I tried to create ocaml version 4.04.0 from a tarball, and then use it to create a unison, but on one of the computers the unison build failed with an error message,

make[1]: Entering directory '/home/norio/Downloads/unison/unison-2.48.4_expand/src' ocamlc -o mkProjectInfo unix.cma str.cma mkProjectInfo.ml File "mkProjectInfo.ml", line 1: Error: Error while linking /home/norio/Downloads/unison/ocaml_for_unison/lib/ocaml/unix.cma(Unix): The external function `unix_has_symlink' is not available if [ -f `which etags` ]; then \ etags *.mli */*.mli *.ml */*.ml */*.m *.c */*.c *.txt \ ; fi make[1]: Leaving directory '/home/norio/Downloads/unison/unison-2.48.4_expand/src' 

I don’t want to go looking for the unix_has_symlink function and devote myself to studying the swamp dependencies of libraries, where many developers fell before civilization appeared, and package developers were developed.

Is there something like opam install ocamlc-4.04 and opam install all-packages ?


Adding

The unix_has_symlink error unix_has_symlink was found on a machine with a 64-bit Linux Mint 18 Cinnamon processor. Is this function part of some unix / linux library, not an ocaml package?

+8
source share
1 answer

To switch to a specific version of the compiler, do

 opam switch create <compiler-version> 

(Note: for the old opam 1.x, it was an opam switch <compiler-version> )

For instance,

 opam switch create 4.07.0 

Or, if you want to create a new new switch that uses the same compiler as another switch, then the syntax

 opam switch create <name> <compiler-version> 

For instance,

 opam switch create myproj 4.07.0 

Please note that if <name> is a folder, a local switch will be created, for example, opam switch./myproj 4.07.0 will create a switch directly in the myproj folder.

To start with a specific version, i.e. When you first install opam, just do

 opam init --compiler=<version> 

For instance,

 opam init --compiler=4.07.0 

To view the list of available versions, do

 opam switch 

To see even more, do

 opam switch list-available 
+16
source

Source: https://habr.com/ru/post/1260609/


All Articles