简体   繁体   English

尝试编译ocaml文件时未绑定的模块核心

[英]Unbound module core while trying to compile ocaml file

i'm having a problem while trying to compile an ocaml file with ocamlc -o hello hello.ml it gives me this error 我在尝试使用ocamlc -o hello hello.ml编译ocaml文件时ocamlc -o hello hello.ml它给了我这个错误

Error: Unbound module Core 错误:未绑定的模块核心

which is weird because when i use utop and import the core std with open Core.Std;; 这很奇怪,因为当我使用utop并使用open Core.Std;;导入core std open Core.Std;; it does work and import it, any ideas of how to solve this problem ? 它确实可以工作并导入,如何解决此问题的任何想法?

Thanks in advance 提前致谢

open Core.Std does not really import core , it just puts its values in scope so that you can refer to Core.Std.x as just x . open Core.Std并没有真正导入core ,只是将其值放在作用域中,以便您可以将Core.Std.x称为x

To import it you need to pass it to require the package somehow in your compiler. 要导入它,您需要传递它以在编译器中以某种方式require该软件包。 The easiest way is to use ocamlfind : 最简单的方法是使用ocamlfind

ocamlfind ocamlc -package core -linkpkg -o hello hello.ml

The corresponding way to do that in utop is by passing -require core on the command line or #require "core" in the REPL. utop执行此操作的相应方法是在命令行上传递-require core或在REPL中传递#require "core"

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

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