Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
ocamlbuild fails to link dependent module
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-06-30 (21:37)
From: Ashish Agarwal <agarwal1975@g...>
Subject: ocamlbuild fails to link dependent module
I cannot get ocamlbuild to link properly under a very specific situation
that involves nested and packed modules. The following is a minimal example
that reproduces the problem.
$ cat a2.mli
val f : unit -> unit

$ cat
let f _ = ()

$ cat
module A = A2

$ cat
let g = Lib.A.f

$ cat sup.mlpack

$ cat
let _ = Sup.B.g ()

Now try compiling:
$ ocamlbuild prog.byte
+ /Users/ashish/godi/bin/ocamlc.opt lib.cmo sup.cmo prog.cmo -o prog.byte
Error while linking lib.cmo: Reference to undefined global `A2'
Command exited with code 2.

The problem is that a2.cmo should be included but is not. The linking is
done correctly if I do any of the following:
- delete a2.mli
- in, directly call Lib.A.f (which is what Sup.B.g is defined as)
- in, directly call B.g, without packing B in Sup

I would appreciate any help. Thank you.