【问题标题】:Ocaml topfind lwtOcaml topfind lwt
【发布时间】:2012-12-27 11:06:31
【问题描述】:

我正在尝试将 lwt 模块与 Ocaml 一起使用

%cat .ocamlinit
#use "topfind";;  
#require "lwt.simple-top";; 
#require "lwt.syntax";;
#require "findlib";;
#require "num.core";;
#load "nums.cma";;
#load "unix.cma";;
#camlp4o;;
open Lwt;;
open Lwt_io;;

当我尝试使用任何 Lwt API 使用此命令进行构建时 “ocamlbuild -use-ocamlfind myFile.native”

我收到此错误: “错误:未绑定模块 Lwt”

当我输入终端 %ocaml 时,它会成功加载,我可以使用 Lwt.API 的

发生了什么事?有什么建议吗?

【问题讨论】:

    标签: ocaml


    【解决方案1】:

    ocamlbuild 不读取 .ocamlinit,它纯粹用于顶层(即 ocaml)。 为了编译依赖 lwt 的项目,您需要指定依赖项,例如:

    ocamlbuild -use-ocamlfind -package lwt myFile.native
    

    另见How to compile ocaml to native code

    【讨论】:

    • 然后我可以把它放在 _tag 文件中
    • 还有顶级是什么意思?
    • toplevel = repl 其他语言。一个交互式 shell,您可以在其中评估代码的 sn-ps 并立即看到结果。
    • 谢谢。你的意思是逐行执行代码的解释器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多