【发布时间】:2017-01-26 03:48:28
【问题描述】:
我在尝试使用 ocamlc -o hello hello.ml 编译 ocaml 文件时遇到问题,它给了我这个错误
错误:未绑定模块核心
这很奇怪,因为当我使用 utop 并使用 open Core.Std;; 导入核心 std 时,它确实可以工作并导入它,关于如何解决这个问题的任何想法?
提前致谢
【问题讨论】:
标签: ocaml
我在尝试使用 ocamlc -o hello hello.ml 编译 ocaml 文件时遇到问题,它给了我这个错误
错误:未绑定模块核心
这很奇怪,因为当我使用 utop 并使用 open Core.Std;; 导入核心 std 时,它确实可以工作并导入它,关于如何解决这个问题的任何想法?
提前致谢
【问题讨论】:
标签: ocaml
open Core.Std 并没有真正导入core,它只是将其值放在范围内,以便您可以将Core.Std.x 引用为x。
要导入它,您需要在编译器中以某种方式将其传递给 require 包。最简单的方法是使用ocamlfind:
ocamlfind ocamlc -package core -linkpkg -o hello hello.ml
在utop 中执行此操作的相应方法是在命令行中传递-require core 或在REPL 中传递#require "core"。
【讨论】: