ocamlfind
Find and link OCaml packages
TLDR
Compile a source file to a native binary and link with packages
Compile a source file to a bytecode binary and link with packages
Cross-compile for a different platform
SYNOPSIS
ocamlfind command [ options ]
PARAMETERS
query package...
Display information about the specified packages.
list
List all installed packages.
printconf var
Print the value of configuration variable var.
opt options
Pass options to the OCaml compiler.
c options
Pass options to the OCaml compiler (short for opt).
ocamlc options
Invoke ocamlc with the specified options.
ocamlopt options
Invoke ocamlopt with the specified options.
ocamldep options
Invoke ocamldep with the specified options.
-package package
Specify a package to be used. Can be repeated to include multiple packages.
-predicates predicates
Specify predicates to be used during package selection. Example: 'native,mt'.
-toolchain toolchain
Specify the toolchain to be used.
-help
Display help message.
DESCRIPTION
ocamlfind
is a command-line tool that helps you manage and utilize OCaml libraries and packages. It acts as a package manager, allowing you to find, link, and compile OCaml code against external libraries. It simplifies the process of building OCaml projects that depend on multiple libraries by automatically locating the necessary compilation and linking flags. ocamlfind
maintains a central registry of installed packages and their metadata. This registry allows it to determine the correct compiler and linker flags for any package. It greatly reduces the complexity of managing dependencies in OCaml projects, making the build process more robust and portable.
It can be used to query information about installed packages, such as their version, location, and available modules. It also integrates with build tools like ocamlbuild
and dune
, further streamlining the development workflow.
CAVEATS
ocamlfind requires a correctly configured OCaml environment. Make sure OCaml is installed and the environment variables are set up properly. Package metadata must be accurate for ocamlfind to work correctly.
CONFIGURATION FILES
ocamlfind uses configuration files to determine how to find and link with libraries. The main configuration file is usually located in /etc/ocamlfind.conf
or $OCAMLFIND_CONF
. These files define the default compiler and linker flags, as well as the paths where packages are located. You can customize these files to tailor ocamlfind to your specific environment.
HISTORY
ocamlfind was developed to address the growing complexity of managing OCaml dependencies. It was designed to provide a centralized and automated way to discover, link, and compile against OCaml libraries. Over time, it has become an integral part of the OCaml ecosystem, adopted by many projects and integrated with popular build tools.
SEE ALSO
ocamlc(1), ocamlopt(1), ocamldep(1), ocamlbuild(1), dune(1)