简体   繁体   English

OCaml 和 Opam:未绑定模块核心

[英]OCaml and Opam: unbound module Core

I'm trying to get an OCaml environment set up, and I've followed the instructions from appendix A of the Real World OCaml beta.我正在尝试设置 OCaml 环境,并且我已按照 Real World OCaml beta 的附录 A 中的说明进行操作。 I set up opam, and installed a version of OCaml with the command我设置了 opam,并使用命令安装了一个 OCaml 版本

$ opam switch 4.01.0dev+trunk

which passed fine.顺利通过。 I then did an然后我做了一个

$ eval `opam config env`

to pull in the changes.拉动变化。 I'm running the correct top level, as我正在运行正确的顶级,因为

$ which ocaml

outputs产出

/home/bryan/.opam/4.01.0dev+trunk/bin/ocaml

I installed the Core package from Jane street, with the command我从 Jane street 安装了 Core 包,使用命令

$ opam install core

Both ocamlfind and opam search show that the package was installed correctly. ocamlfind 和 opam 搜索都显示软件包安装正确。 However when I try to open it either from the repl or in a file, I get the error 'unbound module Core'.但是,当我尝试从 repl 或文件中打开它时,出现错误“未绑定模块核心”。 eg例如

$ ocaml
# open Core;;
Error: Unbound module Core

Is there something I'm missing here?有什么我在这里想念的吗? Why can't OCaml find my installed module?为什么 OCaml 找不到我安装的模块?

So I jumped the gun a bit.所以我有点跳枪了。 I forgot to add some items to my ~/.ocamlinit file.我忘了在我的 ~/.ocamlinit 文件中添加一些项目。 Specifically I forgot to add具体我忘了添加

#use "topfind"
#camlp4o
#thread
#require "core.top"
#require "core.syntax"

as mentioned in Chapter 1. D'oh!如第 1 章所述。天啊!

Please follow the steps in the Real World OCaml Wiki - Installation Instructions .请按照Real World OCaml Wiki - 安装说明中的步骤进行操作

Under Setting up and using utop , the instructions state that you should add:设置和使用 utop 下,说明说明您应该添加:

#use "topfind";;
#thread;;
#camlp4o;;
#require "core.top";;
#require "core.syntax";;

to your ~/.ocamlinit file.到您的~/.ocamlinit文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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