简体   繁体   中英

Unbound Module Stdlib

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.pa stdlib.p.cxma

OCaml version : 4.05.0

The standard library was renamed from Pervasives to Stdlib fairly recently. Your compiler is from before the change; ie, 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM