5

In my project I have a file that uses Core.Std stuff, so I have run

opam install core

and added

open Core.Std

in my file.

When I run

ocamlbuild myprogram.native

it says:

Error: Unbound module Core

pointing to line with the open statement above.

So, I try this:

ocamlbuild -use-ocamlfind -pkgs core.std myprogram.native

and get the following message:

ocamlfind: Package `core.std' not found

So I thought that maybe I needed to run opam install core.std as well, but apparently there is no such thing according to opam. I also tried "open Core.Std;;" in the ocaml repl, but that did not work either. Any ideas?

Calle
  • 366
  • 6
  • 17

2 Answers2

10

You can either use corebuild which is usually shipped with this library or, you can try this:

 ocamlbuild -use-ocamlfind -pkg core

P.S. use ocamlfind list command to view the list of available packages.

P.P.S. In addition to corebuild they usually ship coretop, a script that allows you to run core-enabled top-level. It uses utop underneath the hood, so make sure that you have installed it with opam install utop (if you're using opam), before your experiments.

ivg
  • 34,431
  • 2
  • 35
  • 63
  • How do you supply this flag from myocamlbuild.ml? –  Aug 02 '15 at 16:53
  • "this" is which one? `-use-ocamlfind` or `-pkg core`? – ivg Aug 02 '15 at 20:07
  • The latter; `-pkg core`. –  Aug 02 '15 at 20:23
  • usually they add this to `_tags` file, and `myocamlbuild.ml` is used to determine a correct set of flags based on `_tags`. Depending on your `myocamlbuld.ml`, you need to add `<**/*> : pkg_core` or `<**/*>: package(core)`. Writing your own `myocamlbuild` plugin is an advanced magic, that usually is not required. Even manually filling `_tags` file is quite unusual. So, maybe you're looking in a wrong direction. – ivg Aug 02 '15 at 20:33
  • Oh, I see. Thanks. :) –  Aug 02 '15 at 20:34
5

Remove .std from your ocamlbuild cmd?

Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
  • 2
    Thanks! Now I get a different error message: "ocamlfind: Error from package `threads': Missing -thread or -vmthread switch Command exited with code 2." and -thread or -vmthread are not switches ocamlbuild accepts. – Calle Nov 19 '14 at 22:02
  • 3
    vmthread and thread are tags. You also want, `-tag[s] thread` – nlucaroni Nov 19 '14 at 22:05