Reputation: 373
According to this "Error: unbound module" in OCaml
I should be able to run this
#use "topfind";;
#require "lwt";;
#require "cohttp-lwt-unix";;
as ocaml my_test1.ml
But after I've installed all the libraries and running it as such, I have an error:
$ ocaml my_test.ml
Cannot find file topfind.
Unknown directive `require'.
update
$ ocaml my_test.ml
File "./my_test.ml", line 1:
Error: Reference to undefined global `Mutex'
update2
#use "topfind";;
#require "lwt";;
#require "cohttp-lwt-unix";;
#thread;;
open Cohttp
open Lwt
open Cohttp
open Cohttp_lwt_unix
let () =
Printf.printf ("test1")
;;
and
eval `opam config env`
ocaml test1.ml
same error:
File "./test1.ml", line 1:
Error: Reference to undefined global `Mutex'
Upvotes: 1
Views: 389
Reputation: 3028
ivg
is right in that the interpreter is picking the single-threaded runtime, but that's something you have to fix in your application by adding #thread
yourself:
#use "topfind";;
#thread;;
#require "lwt";;
#require "cohttp-lwt-unix";;
This is related to some recent changes in lwt
and ocamlfind
. You can find some pointers in this bug report I opened recently.
Upvotes: 1
Reputation: 35260
For some reason, the interpreter is picking the single-threaded runtime. Probably, there is some problem with your installation or it is a bug in ocamlfind. If you're using system OCaml installation, then my suggestion would be to switch to OPAM's compiler, e.g.,
opam switch 4.05.0
then install the necessary packages, e.g.,
opam install cohttp-lwt-unix
and do not forget to activate your switch with
eval `opam config env`
If the problem still persists, then try to install another version of OCamlFind. If you still have a problem, then submit a bug report. The code you're showing should work (and works on mine machine).
Upvotes: 1