1
votes

I am trying to use lwt module with 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;;

When I try to use any Lwt API using this command to build "ocamlbuild -use-ocamlfind myFile.native"

I receive this error: "Error: Unbound module Lwt"

When I type in terminal %ocaml it loads successfully and i can use Lwt.API's

What is going on? any suggestion?

1

1 Answers

2
votes

ocamlbuild doesn't read .ocamlinit, it is purely for toplevel (i.e. ocaml). In order to compile lwt-dependent project you will need to specify dependencies, e.g. :

ocamlbuild -use-ocamlfind -package lwt myFile.native

See also How to compile ocaml to native code