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
Compiling recursive modules into a .cma.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-10-20 (13:51)
From: Stéphane Glondu <steph@g...>
Subject: Re: [Caml-list] Compiling recursive modules into a .cma.

Guillaume Yziquel wrote:
> I've been recently trying to compile a module I made. I can load the
> .cmo I generate out of it, but not the .cma I generate out of it.
> [...]
>> # #load "ocaml-yziquel.cma";;
>> Reference to undefined global `Protection'
>> [...]

IIUC, in this .cma, there are (at least) Protection and Chain modules,
the latter depending on the former. However:

> [...]
> Here is the makefile:
> [...]
>> SOURCE = $(wildcard *.ml)
>> [...]
>> [...]
>> 	$(OCAMLC) $(PACKAGES) -a -o ocaml-yziquel.cma $(BYTE_COMPILED_OBJECT)
>> [...]

It seems that chain.cmo is linked before protection.cmo inside the .cma.
 The order of modules inside of a .cma file is important. The behaviour
is the same as if they were #loaded in the same order in a toplevel. Try
writing explicitly all .ml files of $(SOURCE) in topological order.