安装Ocaml Batteries期间出现Unbound module Findlib错误



我已经创建了如下的~/.ocamlinit

let interactive = !Sys.interactive;;
Sys.interactive := false;; (*Pretend to be in non-interactive mode*)
#use "topfind";;
Sys.interactive := interactive;; (*Return to regular interactive mode*)
Toploop.use_silently Format.err_formatter (Filename.concat (Findlib.package_directory "batteries") "battop.ml");;

当我在命令行键入ocaml时,我得到以下错误:

$ ocaml
Objective Caml version 3.12.1
Cannot find file topfind.
File ".ocamlinit", line 6, characters 60-85:
Error: Unbound module Findlib
# 

是什么导致了这个问题,我应该如何解决这个问题?

(我在Debian Wheezy上)

编辑:我已经为ocaml:设置了一个别名

alias ocaml='rlwrap -H /home/nanda/.ocaml_history -D 2 -i -s 10000 ocaml'

感谢dkim,我会发布对我有效的解决方案。希望这能帮助其他人。

Ocaml电池安装流程

为了能够使用包含的ocaml电池,我遵循了以下过程:

sudo apt-get install ocaml ocaml-batteries-included ocaml-doc ledit rlwrap

需要rlwrapledit来添加对OCaml toploop的读线支持。

.bashrc中添加了一个别名,以保存在ocaml toploop中输入的命令。

alias ocaml='rlwrap -H /home/nanda/.ocaml_history -D 2 -i -s 10000 ocaml'

-H指定历史文件名
-D忽略重复
-i不区分大小写
-s限制存储在此文件中的命令数

正如评论中提到的,我在尝试调用ocaml解释器时收到了这个错误。

$ ocaml
Objective Caml version 3.12.1
Cannot find file topfind.
File ".ocamlinit", line 6, characters 60-85:
Error: Unbound module Findlib
# 

我收到这个错误,因为ocaml findlib包没有正确安装。我已经设法通过安装libfindlib-ocaml-dev包来解决这个问题:

sudo apt-get install libfindlib-ocaml-dev

对于一些人来说,当从这里提到的源安装findlib包时,这个问题就解决了

一些更有用的链接:

  1. http://mirror.ocamlcore.org/wiki.cocan.org/tips_for_using_the_ocaml_toplevel.html
  2. http://projects.camlcity.org/projects/dl/findlib-1.2.1/doc/guide-html/quickstart.html
  3. http://www.donadeo.net/post/2010/installing-batteries

最新更新