【问题标题】:Unbound module core while trying to compile ocaml file尝试编译 ocaml 文件时未绑定模块核心
【发布时间】:2017-01-26 03:48:28
【问题描述】:

我在尝试使用 ocamlc -o hello hello.ml 编译 ocaml 文件时遇到问题,它给了我这个错误

错误:未绑定模块核心

这很奇怪,因为当我使用 utop 并使用 open Core.Std;; 导入核心 std 时,它确实可以工作并导入它,关于如何解决这个问题的任何想法?

提前致谢

【问题讨论】:

    标签: ocaml


    【解决方案1】:

    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"

    【讨论】:

    • 伙计,这是我浏览的第 10 篇 SO 帖子。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2014-10-26
    • 2013-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多