Search code examples
ocamlutop

OCaml unable to load "extLib.cma" from toplevel


When I attempt to load the file extLib.cma in utop, OCaml's top level, I get the following error:

Cannot find file extLib.cma

However, if I try to install it using opam I get the following note:

Package extlib is already installed.

What am I doing wrong?


Solution

  • If your purpose is to interactively use some of extLib's functions then

    $ utop
    
    μ> #require "extlib";;
    μ> ExtString.String.explode "ExtLib";;
    - : char list = [E; x; t; L; i; b]
    

    If it's something else, then you may need to specify the exact path to extLib.cma, and something similar to the following should work:

    $ utop
    
    μ> #load "/Users/xxx/.opam/4.02.3/lib/extlib/extLib.cma";;
    

    where /Users/xxx is your home directory/folder; 4.02.3 is my current compiler version, set via opam switch (IIRC, it's system by default).