Chapter 7. FAQs

Table of Contents
Does findlib support the autolink feature of O'Caml 3?
Why does findlib not automatically include the -custom option if linked with C code?
Does findlib support linking of applications as well as packages?
Does Findlib support camlp4?
Why do some people install the .cmx files?
How do I express conflicts?

Does findlib support the autolink feature of O'Caml 3?

Short answer: Findlib is compatible with autolink

The new archive format introduced with O'Caml 3 can store the linker options that are necessary to link an archive. For example:

ocamlc -a -o myarchive.cma mymodule.cmo -cclib -lmylibrary
This command does not only create the new archive myarchive.cma, but it also writes into a special section of that file that the linker option -cclib -lmylibrary is necessary to link this archive.

This means for findlib that most of the "linkopts" attributes in META files have become superflous: The compiler itself already knows the linker options, we do not need to tell the compiler the options. We could simply leave all "linkopts" attributes out.

Of course, the "linkopts" feature of findlib still works. This is necessary because findlib should keep the compatibility with older software, and because "linkopts" is more powerful (you can have conditional linker options).

If you have software that must run in both O'Caml 2 and O'Caml 3 environments, you can make your "linkopts" attribute dependent on the "autolink" predicate. For example:

linkopts = "-cclib -lmylibrary"
linkopts(autolink) = ""
The findlib installation for O'Caml 3 will take the second line which is reasonable because ocamlc already knows how to link; the installation for O'Caml 2 never sets the "autolink" predicate and therefore uses the first line.