Reputation: 351
I am trying to build code using ocamlc however, I got error
Error: Unbound module Stdlib
The /usr/lib/ocaml/
directory includes the following
stdlib.a
stdlib.cma
stdlib.cxma
stdlib.p.a
stdlib.p.cxma
OCaml version : 4.05.0
Upvotes: 1
Views: 3117
Reputation: 29106
The Stdlib
module was introduced in 4.07.0. Before that it was called Pervasives
. It seems like you're mixing installations.
A few commands that might help untangle it:
which ocamlc
will tell you where the compiler is located.ocamlc -config
will tell you where the standard library is expected to be.It is also strongly advised to use opam
, the OCaml Package Manager, to manage OCaml installations as it allows you to switch between multiple installations and gives you access to the latest compiler as soon as it's released.
Upvotes: 1
Reputation: 66793
The standard library was renamed from Pervasives to Stdlib fairly recently. Your compiler is from before the change; i.e., the 4.05.0 compiler has a Pervasives module and no Stdlib module. The code you're trying to compile is most likely from after the change.
There's usually no reason to mention the name of the standard library because it is "pervasive". So you could try removing "Stdlib." wherever you see it. Or you could try renaming it to "Pervasives.".
If the code is much more recent than the 4.05.0 compiler you could encounter other problems, however.
Upvotes: 3