我成功地安装了ocaml-batteries-included和findlib。
我可以无问题地找到-package电池-c mycode.ml`。
而且,如果我做了ocamlfind list,我会得到
$ ocamlfind list
batteries (version: 2.0)
batteries.pa_comprehension (version: 2.0)
batteries.pa_comprehension.syntax (version: 2.0)
batteries.pa_llist (version: 2.0)
batteries.pa_llist.syntax (version: 2.0)
batteries.pa_string (version: 2.0)
batteries.pa_string.syntax (version: 2.0)
batteries.syntax (version: 2.0)
bigarray (version: [distributed with Ocaml])
camlp4 (version: [distributed with Ocaml])
...问题是using batteries in ocaml (toplevel)。
我已经设置了.ocamlinit,如下所示:
#use "topfind";;
Toploop.use_silently
Format.err_formatter (Filename.concat (Findlib.package_directory
"batteries") "battop.ml");;但是当我启动ocaml时,我得到了这样的信息:
$ ocaml
OCaml version 4.00.1
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
Exception: Fl_package_base.No_such_package ("batteries", "").此外,如果我在#list中使用ocaml toplevel,我会得到
# #list;;
bigarray (version: [distributed with Ocaml])
camlp4 (version: [distributed with Ocaml])
camlp4.exceptiontracer (version: [distributed with Ocaml])
camlp4.extend (version: [distributed with Ocaml])
...我看不见batteries 包.
,怎么了?
发布于 2013-02-19 07:24:27
你为什么不使用OPAM?(https://github.com/OCamlPro/opam)
安装OPAM,切换到您喜欢的4.0x编译器版本(例如opam switch 4.00.1),然后运行:opam install batteries。我建议使用opam install utop和使用utop代替香草托普利。在任何一种情况下:
将以下内容放入您的~/.ocamlinit
#use "topfind";;
#require "batteries";;
open Batteries;;只有这样你才能让电池正常工作。
https://stackoverflow.com/questions/14947667
复制相似问题