The findlib user's guide and reference manual

Gerd Stolpmann

The "findlib" library provides a scheme to manage reusable software components (packages), and includes tools that support this scheme. Packages are collections of OCaml modules for which metainformation can be stored. The packages are kept in the filesystem hierarchy, but with strict directory structure. The library contains functions to look the directory up that stores a package, to query metainformation about a package, and to retrieve dependency information about multiple packages. There is also a tool that allows the user to enter queries on the command-line. In order to simplify compilation and linkage, there are new frontends of the various OCaml compilers that can directly deal with packages.

Together with the packages metainformation is stored. This includes a version string, the archives the package consists of, and additional linker options. Packages can also be dependent on other packages. There is a query which finds out all predecessors of a list of packages and sorts them topologically. The new compiler frontends do this implicitly.

Metainformation can be conditional, i.e. depend on a set of predicates. This is mainly used to be able to react on certain properties of the environment, such as if the bytecode or the native compiler is invoked, if the application is multi-threaded, and a few more. If the new compiler frontends are used, most predicates are found out automatically.

There is special support for scripts. A new directive, "#require", loads packages into scripts. Of course, this works only with newly created toploops which include the "findlib" library.

Quickstart

See also the Quickstart page for instructions for the most common cases (this page assumes O'Caml 3.03-alpha, though).


Table of Contents
I. User's guide
1. Packages: Reusable software components
2. Using packages
Listing the installed packages
Looking up package directories
How a package directory looks like
Querying information stored in META files
How to compile and link a program that uses a package
Dependencies
Linker options
3. Dependency analysis of packages
Querying ancestors
Querying descendants
4. A new frontend for ocamlc
Compiling and linking
Creating toploops and runtime systems
Multi-threaded applications
Support for gprof-enabled modules
5. Conditional properties of packages
The standard predicates
Defining additional predicates
6. How to provide your own packages
Step 1: Change your Makefile
Step 2: Write a META file
7. FAQs
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?
II. Reference manual
ocamlfind -- [Command-line interface of the Package manager]
Findlib -- [Module for package management]
Topfind -- [Module to load packages into toploops]
META -- [File that specifies metainformation of OCaml packages]
findlib.conf -- [Configuration of findlib/ocamlfind]
site-lib -- [Location of package directories]