Sebastien
Sebastien

Reputation: 672

Issue in opening a module in OCaml

I'm trying to use the "Batteries" module, but... it doesnt work!

Here is an example:

open Batteries;;

print_endline (dump [5;4;2]);;

I'm compiling with: opam exec ocamlc main.ml the error message is:

File "main.ml", line 1, characters 5-14:
1 | open Batteries;;
         ^^^^^^^^^
Error: Unbound module Batteries

and the Batteries module seems installed:

$ opam install Batteries
[NOTE] Package batteries is already installed (current version is 3.0.0).

What am I missing?

Upvotes: 1

Views: 200

Answers (1)

ivg
ivg

Reputation: 35210

Just installing a library is not enough, you have to tell the compiler that you want to link it (the compiler itself doesn't know anything about opam). There are many compilation and configuration tools available for OCaml, here's just one of the ways to build a binary that uses batteries

ocamlbuild -pkg batteries main.native

Upvotes: 2

Related Questions