The
.cmx object files being combined must have been compiled with
the appropriate
-for-pack option. In the example above,
A.cmx,
B.cmx and
C.cmx must have been compiled with
ocamlopt -for-pack P.
Multiple levels of packing can be achieved by combining
-pack with
-for-pack. Consider the following example:
ocamlopt -for-pack P.Q -c A.ml
ocamlopt -pack -o Q.cmx -for-pack P A.cmx
ocamlopt -for-pack P -c B.ml
ocamlopt -pack -o P.cmx Q.cmx B.cmx
The resulting
P.cmx object file has sub-modules
P.Q,
P.Q.A
and
P.B.
The restriction to systems with GNU binutils has been droped.