安装的软件包,我试图让这段代码:Ocamlbuild并通过OPAM
open Lwt;;
open Cohttp;;
(* a simple function to access the content of the response *)
let content = function
| Some (_, body) -> Cohttp_lwt_unix.Body.string_of_body body
(* launch both requests in parallel *)
let t = Lwt_list.map_p Cohttp_lwt_unix.Client.get
(List.map Uri.of_string
[ "http://example.org/";
"http://example2.org/" ])
(* maps the result through the content function *)
let t2 = t >>= Lwt_list.map_p content
(* launch the event loop *)
let v = Lwt_main.run t2
然而,当我运行
Ocamlbuild file.native
我得到绑定模块的错误。
这些模块是通过OPAM安装,当我运行
ocamlfind query lwt
/home/chris/.opam/system/lib/lwt
ocamlfind query cohttp
/home/chris/.opam/system/lib/cohttp
我怎么Ocamlbuild找到这两个包?
我已经试过
Ocamlbuild -pkgs cohttp,lwt file.native
,并没有奏效。它说了一些关于可能延期的事情。我不认为这是问题。
如果谁能给我正确的代码来做到这一点,将不胜感激。谢谢!
我在过去有一个问题,我在两个不同的位置安装了ocamlbuild,因此这两个安装程序在搜索库时检查不同的目录。你可以尝试:“/home/chris/.opam/bin/ocamlbuild -use-ocamlfind -pkgs cohttp.lwt file.native”(如果它是不完全正确更正路径),以确保您没有看到相同的行为。 –