ocaml - Loading a batteries dependent file into ocamltop -- the interfaces disagree -


here simple ocaml file, meant me understand how load program uses batteries library ocamltop.

batteryassault.ml

open batteries  let main = print_string "hello, world ... powered on" 

i compile bytecode

ocamlfind ocamlc -package batteries -linkpkg batteryassault.ml 

resulting in batteryassault.cmo , batteryassault.cmi, , no errors nor warnings. then, start battery-powered ocamltop with

rlwrap ocamlfind batteries/ocaml 

finally, load file in ocamltop:

#load "batteryassault.cmo" ;; 

and error.

the files batteryassault.cmo , /usr/lib/ocaml/batteries/batteries.cma disagree on interface batteries

i think going on ubuntu installs batteries 2.2.1, reason (installing merlin?) have batteries 2.3.1 installed in opam folder, , moreover, when starting ocamltop batteries above, indicates ocamltop using 2.2.1 version. further, compiling

ocamlfind ocamlc -package batteries -linkpkg batteryassault.ml -verbose 

i find ocamlc using library in opam, i.e. 2.3.1 version.

so question is: the/is there workaround?

usually suggest remove system ocaml installation @ all. otherwise may have such errors.

you should ensure, tools , libraries come same source, in particular case opam.

a usual error forget call

eval `opam config env` 

at point. may recall later this, , activate opam, ending up, parts of application, or opam stack built using opam other parts built system libraries. if made such error, hard guess, when , goes wrong.

but if still don't want remove system batteries, need careful. example, since ocamlfind batteries/ocaml results in loading old version of batteries, can try use trick, make sure batteries topleve loaded opam:

$ `opam config var batteries:lib`/ocaml 

if problem persists, means system broken. consider removing opam stack , making scratch. e.g.,

 rm -rf ~/.opam  opam init --comp=4.02.1  eval `opam config env`  opam install batteries 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -