安裝的軟件包,我試圖讓這段代碼: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」(如果它是不完全正確更正路徑),以確保您沒有看到相同的行爲。 –