【发布时间】:2013-05-28 02:38:14
【问题描述】:
我正在尝试制作这段代码:
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”(如果路径不太正确,请更正路径)以确保您没有看到相同的行为.
标签: ocaml ocamlbuild opam