在Ocaml TopLevel中无法使用FindLib加载电池 [英] Can't load batteries using FindLib in Ocaml TopLevel
问题描述
我成功安装了 ocaml-batteries-included
和 findlib
。
我可以'ocamlfind ocamlc -package batteries -c mycode.ml`没有问题。
另外,如果我做 ocamlfind
$ ocamlfind list
$ b batteries.pa_comprehension(版本:2.0)
battery(版本:2.0)$ b
batteries.pa_comprehension.syntax(版本:2.0)
batteries.pa_llist(版本:2.0)
batteries.pa_llist.syntax(版本:2.0)
batteries.pa_string(版本:2.0)
batteries.pa_string.syntax(版本:2.0)
batteries.syntax(版本:2.0)
bigarray(版本:[与Ocaml一起发行])
camlp4(版本:[与Ocaml分销])
...
< hr>
在 ocaml(toplevel)
中使用电池的问题是。
我已经设置了 .ocamlinit
,如下所示:
#usetopfind;;
Toploop.use_silently
Format.err_formatter(Filename.concat(Findlib.package_directory
batteries)battop.ml);;
但是当我启动 ocaml
时,我得到这:
$ ocaml
OCaml版本4.00.1
Findlib已成功加载。其他指令:
#requirepackage;;加载一个包
#list ;;列出可用软件包
#camlp4o ;;加载camlp4(标准语法)
#camlp4r ;;加载camlp4(修订语法)
#predicatesp,q,...;;设置这些谓词
Topfind.reset();;强制该软件包将重新加载$ b $ b #thread ;;启用线程
例外:Fl_package_base.No_such_package(batteries,)。
此外,如果我在 #list
中 ocaml toplevel
,我得到
##list ;;
bigarray(版本:[与Ocaml分销])
camlp4(版本:[与Ocaml分销])
camlp4.exceptiontracer(版本:[与Ocaml分销])
camlp4。扩展(版本:[与Ocaml分发])
...
I无法看到 batteries
包。
$ b
有什么问题? 解决方案
是否有原因导致您不使用OPAM? ( https://github.com/OCamlPro/opam )
安装OPAM,切换到您最喜欢的4.0x编译器版本(例如 opam switch 4.00.1
),然后运行: opam安装电池
。我建议使用 opam install utop
并使用 utop
代替原始顶级。无论在哪种情况下:
将以下内容放入您的〜/ .ocamlinit
#usetopfind;;
#requirebatteries;;
打开电池;;
这就是所有你需要的电池。
I successfully installed ocaml-batteries-included
and findlib
.
I can do 'ocamlfind ocamlc -package batteries -c mycode.ml` without problems.
Also, if I do ocamlfind list
, I get
$ 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])
...
The problem is using batteries
in ocaml (toplevel)
.
I have set up .ocamlinit
as told:
#use "topfind";;
Toploop.use_silently
Format.err_formatter (Filename.concat (Findlib.package_directory
"batteries") "battop.ml");;
but when I launch ocaml
, I get this:
$ 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", "").
Further, if I do #list
in ocaml toplevel
, I get
# #list;;
bigarray (version: [distributed with Ocaml])
camlp4 (version: [distributed with Ocaml])
camlp4.exceptiontracer (version: [distributed with Ocaml])
camlp4.extend (version: [distributed with Ocaml])
...
I can't see batteries
package.
What's the problem?
Is there a reason why you're not using OPAM? (https://github.com/OCamlPro/opam)
Install OPAM, switch to your favorite version of the 4.0x compiler (for example opam switch 4.00.1
), and run: opam install batteries
. I recommend doing opam install utop
and using utop
instead of the vanilla toplevel. In either case:
Put the following in your ~/.ocamlinit
#use "topfind";;
#require "batteries";;
open Batteries;;
This is all you need to get batteries working.
这篇关于在Ocaml TopLevel中无法使用FindLib加载电池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!