LinuxCommandLibrary

ocamlfind

package manager for OCaml libraries

TLDR

Compile with package

$ ocamlfind ocamlc -package [str] -linkpkg [program.ml] -o [program]
copy
Compile native with packages
$ ocamlfind ocamlopt -package [core,yojson] -linkpkg [program.ml] -o [program]
copy
List installed packages
$ ocamlfind list
copy
Show package info
$ ocamlfind query [package]
copy
Show package directory
$ ocamlfind query -d [package]
copy
Show package dependencies
$ ocamlfind query -r [package]
copy
Install package
$ ocamlfind install [package] META [*.cmi] [*.cmo] [*.cma]
copy
Remove package
$ ocamlfind remove [package]
copy

SYNOPSIS

ocamlfind [ocamlc] [ocamlopt] [query] [list] [install] [-package pkgs] [options] [files]

DESCRIPTION

ocamlfind is the package manager for OCaml libraries. It locates installed packages and configures compiler invocations automatically.
The tool wraps OCaml compilers, adding include paths and library references based on package specifications. This simplifies builds by handling library dependencies.
Each package has a META file describing its components, dependencies, and locations. Query commands extract this information for build systems and scripts.
Package installation places libraries in a central repository with META files. This standardized layout enables reliable discovery and linking.
Dependencies are resolved transitively. Specifying a high-level package automatically includes its prerequisites.
Integration with build systems like Dune is common. Many projects use ocamlfind directly or through wrapper tools.

PARAMETERS

ocamlc ARGS

Run bytecode compiler.
ocamlopt ARGS
Run native compiler.
query PKG
Query package information.
list
List installed packages.
install PKG FILES
Install package.
remove PKG
Remove package.
-package PKGS
Packages to use (comma-separated).
-linkpkg
Link packages into executable.
-predicates PREDS
Set predicates.
-syntax SYNTAX
Set syntax extension.
-d
Show package directory.
-r
Recursive dependencies.

CAVEATS

Replaced by opam for package installation in modern projects. Manual META file creation can be error-prone. Not all packages include META files.

HISTORY

ocamlfind (findlib) was created by Gerd Stolpmann starting in the early 2000s to standardize OCaml library management. It became the foundation for OCaml's package ecosystem, later complemented by opam for downloading and installing packages.

SEE ALSO

ocaml(1), ocamlc(1), ocamlopt(1), opam(1), dune(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community