genos
genos

Reputation: 51

Unbound module core while trying to compile ocaml file

i'm having a problem while trying to compile an ocaml file with ocamlc -o hello hello.ml it gives me this error

Error: Unbound module Core

which is weird because when i use utop and import the core std with open Core.Std;; it does work and import it, any ideas of how to solve this problem ?

Thanks in advance

Upvotes: 5

Views: 1461

Answers (1)

Étienne Millon
Étienne Millon

Reputation: 3028

open Core.Std does not really import core, it just puts its values in scope so that you can refer to Core.Std.x as just x.

To import it you need to pass it to require the package somehow in your compiler. The easiest way is to use ocamlfind:

ocamlfind ocamlc -package core -linkpkg -o hello hello.ml

The corresponding way to do that in utop is by passing -require core on the command line or #require "core" in the REPL.

Upvotes: 7

Related Questions