1

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?

Jackson Tale
  • 25,428
  • 34
  • 149
  • 271

1 Answers1

4

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.

rgrinberg
  • 9,638
  • 7
  • 27
  • 44
  • Hi I have done all these. As I indicated in the beginning, `I successfully installed ocaml-batteries-included and findlib. I can do 'ocamlfind ocamlc -package batteries -c mycode.ml` without problems.` I can use batteries in file but not in toplevel. I get `# #require "batteries";; No such package: batteries` error. – Jackson Tale Feb 19 '13 at 09:52
  • I have tried `opam switch 4.00.1` and `opam install batteries`, still I can't find `batteries` in `ocaml toplevel`. – Jackson Tale Feb 19 '13 at 12:00
  • have you done `eval \`opam config env\`` after `opam switch 4.00.1`? I tested my instructions on a clean install and they've worked perfectly for me. – rgrinberg Feb 19 '13 at 13:29
  • Ok, I just tried `opam config -evn`. still not working for batteries.Exception: Fl_package_base.No_such_package ("batteries", ""). – Jackson Tale Feb 19 '13 at 14:58