Installing and using modules

Hi there.

I have a very basic question regarding installing modules with opam and using them in ocaml.
In my environment installing the module with opam does not mean that it can be used in ocaml.

For example after installing eigen I cannot simply make open Eigen.
I am getting:
Error: Unbound module Eigen

Now when specifying the module directory explicitly with
ocaml -I $(opam var lib)/eigen

I am getting:
Error: Reference to undefined global `Eigen’

Actually the $(opam var lib) is pointing to:

Is my installation broken or what is necessary to open the modules flawlessly?

If you want to compile things by hand and use libraries installed by opam you should use ocamlfind. Read a short introduction here.

In your particular case you should likely do a :

ocamlfind ocamlc -linkpkg -package eigen

Thank you! that works for compilation.
What can I do to find the library in toplevel (ocaml)?

#use "topfind";;
#require "eigen";;
1 Like