ocamllinker-errorsocaml-core

How to link OCaml object file with Core module?


I have simple program, which uses function from Core.Std module, e.g.:

open Core.Std
let _ = List.last [1;2;3]

I can compile and link it by ocamlfind or ocamlbuild:

ocamlfind ocamlc -package core -linkpkg -thread app.ml 
ocamlbuild -use-ocamlfind -pkgs core -tag thread app.native

But I don't know how to compile and link such file using "normal" OCaml compiler:

ocamlc -c -I ~/.opam/system/lib/core_kernel/ -I ~/.opam/system/lib/core/ app.ml 
ocamlc ~/.opam/system/lib/core_kernel/core_kernel.cma ~/.opam/system/lib/core/core.cma app.cmo 

Last of above commands gives the following error:

File "_none_", line 1:
Error: Error on dynamically loaded library: /home/maciej/.opam/system/lib/stublibs/dllcore_kernel_stubs.so: /home/maciej/.opam/system/lib/stublibs/dllcore_kernel_stubs.so: undefined symbol: caml_ba_alloc

What am I doing wrong?


Solution

  • You can use ocamlfind ocamlc -only-show … to see the full command constructed by ocamlfind . Your error points towards some missing transitive dependencies of Core and an old version of OCaml and Core.