Echo_Zero
Echo_Zero

Reputation: 25

xxx.cmi is not a compiled interface for this version of OCaml

There is two files a.cmo and a.cmi which are compiled by ocaml 4.13.1.

I write a file test.ml which only contains one line code: open A

Now, I want to use command: ocamlc -o test.exe a.cmo test.ml to compile the test.ml in the ocaml 4.14.0 environment(cygwin), and I got an error: a.cmi is not a compiled interface for this version of OCaml, I know this error is caused by ocaml version.But I want to know :

Is there any way to compile to get the a.cmo and a.cmi file independent of the ocaml version? In other words, how can I compile the test.ml file linked with a.cmo file and don't need to consider who uses which ocaml version to compile to get this a.cmo?

Does such a method exist? Or do I have to change the version of ocaml?

Upvotes: 0

Views: 712

Answers (1)

octachron
octachron

Reputation: 18912

The compiled artifacts of the OCaml compiler are versioned to avoid consistency issues and cross-version bugs. By design, there is no way around this security net.

Upvotes: 3

Related Questions