Thank you. That does it. However, it seems not analogous to code compilation, for which what I did was add

      ocaml_lib ~extern:true ~dir:"~/mylibs" "mylib2";

to myocamlbuild.ml and then use the _tags file to specify which files require mylib2. I wonder why the call to ocamldoc cannot use the same dependency information generated to compile an interface file. The same libraries are needed to compile an interface file to a cmi file or to documentation.


On Tue, Dec 23, 2008 at 5:32 AM, Nicolas Pouillard <nicolas.pouillard@gmail.com> wrote:
Excerpts from Ashish Agarwal's message of Tue Dec 23 03:01:38 +0100 2008:
> How can I get ocamlbuild to include paths to external libraries when
> building documentation?
> Ocamlbuild gives me errors when building documentation, when my interface
> files contain references to an external library. I have set up my plugin and
> _tags file to correctly compile the code, but cannot get the documentation
> to work. The command that ocamlbuild executes is [1], which gives error
> [2]. Module M is declared in an external library. I get no errors if I
> manually type [3], where ~/mylibs contains the appropriate library.
> [1] ocamlfind ocamldoc -dump a.odoc a.mli
> [2] Unbound module M
> [3] ocamlfind ocamldoc -dump a.odoc -I ~/mylibs/ a.mli

You should give the same flags for building and generating the documentation,
for instance if you have:

  flag ["ocaml", "compile"] (S[A"-I"; A".../mylibs"])

Then you need:

  flag ["ocaml", "doc"] (S[A"-I"; A".../mylibs"])

HTH,

--
Nicolas Pouillard aka Ertai