ocamlfind

NAME

ocamlfind - [Command-line interface of the Package manager]\c

SYNOPSIS

       ocamlfind query [-help | other options] \c
package_name\c
 ...\c


   or: ocamlfind ocamlc [-help | other options] \c file\c  ...\c
   or: ocamlfind ocamlcp [-help | other options] \c file\c  ...\c
   or: ocamlfind ocamlmktop [-help | other options] \c file\c  ...\c
   or: ocamlfind ocamlopt [-help | other options] \c file\c  ...\c
   or: ocamlfind ocamldoc [-help | other options] \c file\c  ...\c
   or: ocamlfind ocamldep [-help | other options] \c file\c  ...\c
   or: ocamlfind ocamlbrowser [-help | other options]\c
   or: ocamlfind install [-help | other options] \c package_name\c  \c file\c  ...\c
   or: ocamlfind remove [-help | other options] \c package_name\c
   or: ocamlfind list [-describe]\c
   or: ocamlfind printconf [ variable ]\c
   or: ocamlfind \c package\c /\c command\c  \c arg\c  ...\c

Optional toolchain selection by:\c
  ocamlfind -toolchain \c name\c  ...\c

THE 'query' SUBCOMMAND

Synopsis

ocamlfind query [ -predicates \c
p\c
  | \c


                  -format \c f\c  |\c
                  -long-format | -l |\c
                  -i-format |\c
                  -l-format | \c
                  -a-format |\c
                  -o-format | \c
                  -p-format |\c
                  -prefix \c p\c  |\c
                  -separator \c s\c  | \c
                  -suffix \c s\c  |\c
                  -descendants | -d |\c
                  -recursive  | -r ] \c package\c  ...\c

Description

This command looks packages up, sorts them optionally, and\c prints attributes of them. If the option -recursive (short: -r) is not\c specified, exactly the packages given on the command line are looked\c up; if -recursive is present, the packages and all their ancestors, or\c if -descendants (short: -d) is present, too, all their descendants are printed.\c
Package lookup and the selection of the attributes of the packages can\c be modified by specifying predicates; without a -predicates option the\c empty set of predicates is used. Note that even the lookup is\c influenced by the set of actual predicates as the "requires" variables\c may be conditional.\c
What is printed about a package depends on the specified format; there\c are a number of options that modify the format. Some formats denote\c sets of values (such as -format %a), in which case multiple output\c records are printed for every package. (It is even possible to specify\c formats denoting the Cartesian product of sets, such as -format %a%o,\c but this does not make sense.) Before the first output record the\c prefix is printed, and the suffix after the last record. Between two\c records the separator is printed.\c

Options

-predicates p\c
Sets the set of actual predicates. The argument\c p\c is a list of predicate names separated\c by commas and/or whitespace. If multiple -predicates options are\c given, the union of all specified sets is effectively used.\c
-format f\c
Sets the format to the string\c f\c . Characters preceded by a percent sign\c are interpreted as placeholders; all other characters mean\c themselves. The defined placeholders are listed below.\c The default format is "%d".\c
-long-format or -l\c
Sets the format such that all relevant variables are printed.\c
-i-format\c
Same as -format "-I %d", i.e. directory options for ocamlc are printed.\c
-l-format\c
Same as -format "-ccopt -L%d", i.e. directory options for the\c linker backend are printed.\c
-a-format\c
Same as -format "%a", i.e. archive file names are printed.\c
-o-format\c
Same as -format "%o", i.e. linker options are printed.\c
-p-format\c
Same as -format "%p", i.e. package names are printed.\c
-prefix p\c
Sets the prefix that is printed before the first output record\c to the given string. The default prefix is the empty string.\c
-suffix s\c
Sets the suffix that is printed after the last output record\c to the given string. The default suffix is the empty string.\c
-separator s\c
Sets the separator that is printed between output records to\c the given string. The default separator is a linefeed character.\c
-recursive or -r\c
Not only the packages given on the command line are queried\c but also all ancestors or descendants. If the option -descendants is\c specified, too, the descendants are printed, otherwise the\c ancestors. The packages are topologically sorted.\c
-descendants -d\c
Instead of the ancestors the descendants of the\c given packages are queried. This option implies -recursive\c .\c

Placeholders meaningful in the -format option

%%\c
Replaced by a single percent sign\c
%p\c
Replaced by the package name\c
%d\c
Replaced by the package directory\c
%D\c
Replaced by the package description\c
%v\c
Replaced by the version string\c
%a\c
Replaced by the archive filename. If there is more\c than one archive, a separate output record is printed for every archive.\c
%A\c
Replaced by the list of archive filenames.\c
%o\c
Replaced by one linker option. If there is more than\c one option, a separate output record is printed for every option.\c
%O\c
Replaced by the list of linker options.\c
%(\c property\c )\c
Replaced by the value of the property named in parentheses,\c or the empty string if not defined.\c

THE SUBCOMMANDS 'ocamlc', 'ocamlcp', 'ocamlopt', and 'ocamlmktop'

Synopsis

ocamlfind ( ocamlc | ocamlcp | ocamlopt | ocamlmktop )\c


          [ -package \c package-name-list\c  |\c
            -linkpkg |\c
            -predicates \c pred-name-list\c  |\c
            -dontlink \c package-name-list\c  |\c
            -syntax \c pred-name-list\c  |\c
            -ppopt \c camlp4-arg\c  |\c
            -dllpath-pkg \c package-name-list\c  |\c
            -dllpath-all |\c
            -passopt \c arg\c  |\c
            \c standard-option\c  ]\c
          \c file\c  ...\c

Description

These subcommands are drivers for the compilers with the same names,\c i.e. "ocamlfind ocamlc" is a driver for "ocamlc", and so on. The\c subcommands understand all documented options of the compilers (here\c called standard-options\c ), but also a few\c more options. If these subcommands are invoked only with standard\c options, they behave as if the underlying compiler had been called\c directly. The extra options modify this.\c
Internally, these subcommands transform the given list of options and\c file arguments into an invocation of the driven compiler. This\c transformation only adds options and files, and the relative order of\c the options and files passed directly is unchanged.\c
If there are -package options, additional directory search specifiers\c will be included ("-I", and "-ccopt -I"), such that files of all named\c packages and all ancestors can be found.\c
The -linkpkg option causes that the packages listed in the -package\c options and all necessary ancestors are linked in. This means that the\c archive files implementing the packages are inserted into the list of\c file arguments.\c
As the package database is queried a set of predicates is needed. Most\c predicates are set automatically, see below, but additional predicates\c can be given by a -predicates option.\c
If there is a -syntax\c option, the drivers assume that\c a preprocessor is to be used. In this case, the preprocessor command\c is built first in a preprocessor stage, and this command is passed to the\c compiler using the -pp\c option. The set of predicates\c in the preprocessor stage is different from the set in the compiler/linker\c stage.\c

Options for compiling and linking

Here, only the additional options not interpreted by the compiler but\c by the driver itself, and options with additional effects are explained.\c Some options are only meaningful for the preprocessor call, and are\c explained below.\c
-package package-name-list\c
Adds the listed package names to the set of included\c packages. The package names may be separated by commas and/or\c whitespace. In the transformed command, for every package of the set\c of included packages and for any ancestor a directory search option\c is inserted after the already given options. This means that\c "-I" and "-ccopt -I" options are added for every package directory.\c
-linkpkg\c
Causes that in the transformed command all archives\c of the packages specified by -packages and all their ancestors are\c added to the file arguments. More precisely, these archives are\c inserted before the first given file argument. Furthermore, "-ccopt\c -L" options for all package directories, and the linker options of\c the selected packages are added, too. Note that the archives are\c inserted in topological order while the linker options are added in\c reverse toplogical order.\c
-predicates pred-name-list\c
Adds the given predicates to the set of actual\c predicates. The predicates must be separated by commas and/or\c whitespace.
-dontlink package-name-list\c
This option modifies the behaviour of\c -linkpkg. Packages specified here and all ancestors are not linked\c in. Again the packages are separated by commas and/or whitespace.\c
-dllpath-pkg package-name-list\c
For these packages -dllpath\c options\c are added to the compiler command. This may be useful when the ld.conf\c file is not properly configured.\c
-dllpath-all\c
For all linked packages -dllpath\c options\c are added to the compiler command. This may be useful when the ld.conf\c file is not properly configured.\c
-passopt arg\c
The argument arg\c is\c passed directly to the underlying compiler. This is needed to\c specify undocumented compiler options.\c
-verbose\c
This standard option is interpreted by the driver, too.\c
-thread\c
This standard option causes that the predicate "mt"\c is added to the set of actual predicates. If POSIX threads are available,\c the predicate "mt_posix" is selected, too. If only VM threads are\c available, the predicate "mt_vm" is included into the set, and the\c compiler switch is changed into -vmthread.\c
Note that the presence of the "mt" predicate triggers special\c fixup of the dependency graph (see below).\c
-vmthread\c
This standard option causes that the predicates "mt"\c and "mt_vm" are added to the set of actual predicates.\c
Note that the presence of the "mt" predicate triggers special\c fixup of the dependency graph (see below).\c
-p\c
This standard option of "ocamlopt" causes that the\c predicate "gprof" is added to the set of actual predicates.\c

Options for preprocessing

The options relevant for the preprocessor are the following:\c
-package package-name-list\c
These packages are considered while looking up the\c preprocessor arguments. (It does not cause problems that the same\c -package option is used for this purpose, because the set of predicates\c is different.) It is recommended to mention at least camlp4\c here if the preprocessor is going to be used.\c
-syntax pred-name-list\c
These predicates are assumed to be true in addition\c to the standard preprocessor predicates. See below for a list.\c
-ppopt camlp4-arg\c
This argument is passed to the camlp4 call.\c

Predicates for compiling and linking

byte\c
The "byte" predicate means that one of the bytecode compilers is\c used. It is automatically included into the predicate set if the\c "ocamlc", "ocamlcp", or "ocamlmktop" compiler is used.\c
native\c
The "native" predicate means that the native compiler is used. It is\c automatically included into the predicate set if the "ocamlopt"\c compiler is used.\c
toploop\c
The "toploop" predicate means that the toploop is available in the\c linked program. This predicate is only set when the toploop is actually\c being executed, not when the toploop is created (this changed in version\c 1.0.4 of findlib).\c
create_toploop\c
This predicate means that a toploop is being created (using\c ocamlmktop).\c
mt\c
The "mt" predicate means that the program is multi-threaded. It is\c automatically included into the predicate set if the -thread option is\c given.
mt_posix\c
The "mt_posix" predicate means that in the case "mt" is set, too, the\c POSIX libraries are used to implement threads. "mt_posix" is automatically\c included into the predicate set if the variable "type_of_threads" in the\c META description of the "threads" package has the value "posix". This\c is normally the case if "findlib" is configured for POSIX threads.\c
mt_vm\c
The "mt_vm" predicate means that in the case "mt" is set, too, the\c VM thread emulation is used to implement multi-threading.\c
gprof\c
The "gprof" predicate means that in the case "native" is set, too, the\c program is compiled for profiling. It is automatically included into\c the predicate set if "ocamlopt" is used and the -p option is in\c effect.\c
autolink\c
The "autolink" predicate means that ocamlc is able to perform automatic\c linking. It is automatically included into the predicate set if ocamlc\c knows automatic linking (from version 3.00), but it is not set if the\c -noautolink option is set.\c
syntax\c
This predicate is set if there is a -syntax\c option. It is set both for the preprocessor and the compiler/linker stage,\c and it can be used to find out whether the preprocessor is enabled or not.\c

Predicates for preprocessing

preprocessor\c
This predicate is always set while looking up the\c preprocessor arguments. It can be used to distinguish between the\c preprocessor stage and the compiler/linker stage.\c
syntax\c
This predicate is set if there is a -syntax\c option. It is set both for the preprocessor and the compiler/linker stage,\c and it can be used to find out whether the preprocessor is enabled or not.\c
camlp4o\c
This is the reserved predicate for the standard O'Caml syntax.\c It can be used in the -syntax\c predicate list.\c
camlp4r\c
This is the reserved predicate for the revised O'Caml syntax.\c It can be used in the -syntax\c predicate list.\c

Special behaviour of 'ocamlmktop'

As there is a special module Topfind\c that\c supports loading of packages in scripts, the "ocamlmktop" subcommand\c can add initialization code for this module. This extra code is\c linked into the executable if "findlib" is in the set of effectively\c linked packages.

Fixup of the dependency graph for multi-threading

For a number of reasons the presence of the "mt" predicate triggers\c that (1) the package "threads" is added to the list of required packages\c and (2) the package "threads" becomes prerequisite of all other packages\c (except of itself and a few hardcoded exceptions). The effect is that\c the options -thread and -vmthread automatically select the "threads"\c package, and that "threads" is inserted at the right position in the\c package list.\c

Extended file naming

At a number of places one can not only refer to files by absolute\c or relative path names, but also by extended names. These have two\c major forms: "+\c name\c "\c refers to the subdirectory name\c of the\c standard library directory, and "@\c name\c "\c refers to the package directory of the package name\c .\c Both forms can be continued by a path, e.g. "@netstring/netstring_top.cma".\c
You can use extended names: (1) With -I\c options,\c (2) as normal file arguments of the compiler, (3) in the "archive" property of packages.\c

How to set the names of the compiler executables

Normally, the O'Caml bytecode compiler can be called under the name\c ocamlc\c . However, this is not always true; sometimes a\c different name is chosen.\c
You can instruct ocamlfind to call executables with other names than\c ocamlc\c , ocamlopt\c ,\c ocamlmktop\c , and ocamlcp\c . If present,\c the environment variable OCAMLFIND_COMMANDS\c is interpreted\c as a mapping from the standard names to the actual names of the executables. It\c must have the following format:\c
standardname1\c
=\c
actualname1\c
 \c
standardname2\c
=\c
actualname2\c
 ...\c
Example: You may set OCAMLFIND_COMMANDS\c as follows:\c
OCAMLFIND_COMMANDS='ocamlc=ocamlc-3.00 ocamlopt=ocamlopt-3.00'\c


export OCAMLFIND_COMMANDS\c
Alternatively, you can change the configuration file\c findlib.conf\c .\c

THE 'ocamldep' SUBCOMMAND

Synopsis

ocamlfind ocamldep [-package \c
package-name-list\c
 |\c


                    -syntax \c pred-name-list\c  |\c
                    -ppopt \c camlp4-arg\c  |\c
                    -passopt \c arg\c  |\c
                    -verbose |\c
                    \c standard-option\c ] \c file\c  ...\c

Description

This command is a driver for the tool ocamldep\c of the\c O'Caml distribution. This driver is only useful in conjunction with\c the preprocessor camlp4; otherwise it does not provide more functions\c than ocamldep\c itself.\c

Options

Here, only the additional options not interpreted by ocamldep\c but\c by the driver itself, and options with additional effects are explained.\c
-package package-name-list\c
The packages named here are only used to look up the\c preprocessor options. The package camlp4\c should be\c specified anyway, but further packages that add capabilities to the\c preprocessor can also be passed.\c
-syntax pred-name-list\c
The predicates that are in effect during the look-up\c of the preprocessor options. At least, either camlp4o\c (selecting the normal syntax), or camlp4r\c (selecting\c the revised syntax) should be specified.\c
-ppopt camlp4-arg\c
An option that is passed through to the camlp4 call.\c
-passopt arg\c
An option that is passed through to the ocamldep call.\c
-verbose\c
Displays the resulting ocamldep command (for debugging)\c

Example

A typical way of using this driver:\c
ocamlfind ocamldep -package camlp4,xstrp4 -syntax camlp4r file1.ml file2.ml\c
This command outputs the dependencies of file1.ml\c and\c file2.ml\c , although these modules make use of the\c syntax extensions provided by xstrp4\c and are written\c in revised syntax.\c

THE 'ocamlbrowser' SUBCOMMAND

Synopsis

ocamlfind ocamlbrowser [-package \c
package-name-list\c
 |\c


                        -all |\c
                        -passopt \c arg\c  ]\c

Description

This driver calls the ocamlbrowser\c with package options.\c With -package\c , the specified packages are included into\c the search path of the browser, and the modules of these packages become\c visible (in addition to the standard library). The option -all\c causes that all packages are selected that are managed by findlib.\c
As for other drivers, the option -passopt\c can be used\c to pass arguments directly to the ocamlbrowser\c program.\c

THE SUBCOMMAND 'ocamldoc'

Synopsis

ocamlfind ocamldoc\c


          [ -package \c package-name-list\c  |\c
            -predicates \c pred-name-list\c  |\c
            -syntax \c pred-name-list\c  |\c
            -ppopt \c camlp4-arg\c  |\c
            \c standard-option\c  ]\c
          \c file\c  ...\c

Description

This subcommand is a driver for ocamldoc. It undestands all options\c ocamldoc supports plus the mentioned findlib options. Basically,\c the -package options are translated into -I options, and the selected\c syntax options are translated into camlp4 options.\c

Options

Here, only the additional options not interpreted by ocamldep\c but\c by the driver itself, and options with additional effects are explained.\c
-package package-name-list\c
Adds the listed package names to the set of included\c packages. The package names may be separated by commas and/or\c whitespace. In the transformed command, for every package of the set\c of included packages and for any ancestor a directory search option\c is inserted after the already given options. This means that\c "-I" options are added for every package directory.\c
-predicates pred-name-list\c
Adds the given predicates to the set of actual\c predicates. The predicates must be separated by commas and/or\c whitespace.
-syntax pred-name-list\c
The predicates that are in effect during the look-up\c of the preprocessor options. At least, either camlp4o\c (selecting the normal syntax), or camlp4r\c (selecting\c the revised syntax) should be specified.\c
-ppopt camlp4-arg\c
An option that is passed through to the camlp4 call.\c

THE 'install' SUBCOMMAND

Synopsis

ocamlfind install [ -destdir \c
directory\c
 ]\c


                  [ -metadir \c directory\c  ]\c
                  [ -ldconf \c path\c  ]\c
                  [ -dont-add-directory-directive ]\c
                  [ -patch-version \c string\c  ]\c
                  [ -patch-rmpkg \c name\c  ]\c
                  [ -patch-archives ]\c
                  [ -dll ] [ -nodll ] [ -optional ]\c
                  \c package_name\c  \c file\c  ...\c

Description

This subcommand installs a new package either at the default location\c (see the variable destdir\c of\c findlib.conf\c ), or in the directory\c specified by the -destdir option. This\c means that a new package directory is created and that the files on\c the command line are copied to this directory. It is required that a\c META\c file is one of the files copied to the target\c directory.\c
Note that package directories should be flat (no\c subdirectories). Existing packages are never overwritten.\c
It is possible to have a separate directory for all the META files. If\c you want that, you have either to set the variable\c metadir\c of findlib.conf\c , or to specify the\c -metadir option. In this case, the file called META is copied to the\c specified directory and renamed to META.p (where p is the package\c name), while all the other files are copied to the package\c directory as usual. Furthermore, the META file is modified such that the\c directory\c variable contains the path of the package\c directory.
The option -dont-add-directory-directive prevents the installer from\c adding a directory\c variable.\c
If there are files ending in the suffixes .so\c or\c .dll\c , the package directory will be added to the\c DLL configuration file ld.conf\c , such that the dynamic\c loader can find the DLL. The location of this file can be overriden by\c the -ldconf option. To turn this feature off, use "-ldconf ignore";\c this causes that the ld.conf file is not modified.\c
However, if there is a stublibs directory in site-lib, the DLLs are not\c installed in the package directory, but in this directory that is\c shared by all packages that are installed at the same location.\c In this case, the configuration file ld.conf\c is\c not modified, so you do not need to say "-ldconf ignore" if you\c prefer this style of installation.\c
The options -dll and -nodll can be used to control exactly which files\c are considered as DLLs and which not. By default, the mentioned\c suffix rule is in effect: files ending in ".so" (Unix) or ".dll"\c (Windows) are DLLs. The switch -dll changes this, and all following\c files are considered as DLLs, regardless of their suffix. The switch -nodll expresses that the following files are not DLLs, even if they\c have a DLL-like suffix. For example, in the following call the files\c f1 and f2 are handled by the suffix rule; f3 and f4 are DLLs anyway;\c and f5 and f6 are not DLLs:\c
ocamlfind install p f1 f2 -dll f3 f4 -nodll f5 f6\c
The switch -optional declares that all following files are optional,\c i.e. the command will not fail if files do not exist.\c
The -patch options may be used to change the contents of the META files\c while it is being installed. The option -patch-version changes the\c contents of the top-level "version" variable. The option -patch-rmpkg\c removes the given subpackage. The option -patch-archives is experimental,\c in particular it removes all non-existing files from "archive" variables,\c and even whole subpackages if the archives are missing.\c

THE 'remove' SUBCOMMAND

Synopsis

ocamlfind remove [ -destdir \c
directory\c
 ]\c


                 [ -metadir \c directory\c  ]\c
                 [ -ldconf \c path\c  ]\c
                 \c package_name\c

Description

The package will removed if it is installed at the default location (see the variable destdir\c of\c findlib.conf\c ). If the package\c resides at a different location, it will not be removed by default;\c however, you can pass an alternate directory for packages by the\c -destdir option. (This must be the same directory as specified at\c installation time.)\c
Note that package directories should be flat (no subdirectories); this\c subcommand cannot remove deep package directories.
If you have a separate directory for META files, you must either\c configure this directory by the metadir\c variable\c of findlib.conf\c , or by specifying\c the -metadir option.\c
The command does not fail if the package and/or the META\c file cannot be located. You will get a warning only in this case.\c
If the package directory is mentioned in the ld.conf\c configuration file for DLLs, it will be tried to remove this entry\c from the file. The location of this file can be overriden by\c the -ldconf option. To turn this feature off, use "-ldconf ignore";\c this causes that the ld.conf file is not modified.\c
If there is a stublibs directory, it is checked whether the package\c owns any of the files in this directory, and the owned files will\c be deleted.\c

THE 'list' SUBCOMMAND

Synopsis

ocamlfind list [-describe]\c

Description

This command lists all packages in the search path. The option -describe\c outputs the package descriptions, too.\c

THE 'printconf' SUBCOMMAND

Synopsis

ocamlfind printconf [ conf | path | destdir | metadir | stdlib | ldconf ]\c

Description

This command prints the effective configuration after reading the\c configuration file, and after applying the various environment\c variables overriding settings. When called without arguments, the command\c prints all configuration options in a human-readable form. When called\c with an argument, only the value of the requested option is printed without\c explaining texts:\c
conf\c
Prints the location of the configuration file findlib.conf\c
path\c
Prints the search path for packages. The members of the\c path are separated by linefeeds.\c
destdir\c
Prints the location where package are installed and\c removed by default.\c
metadir\c
Prints the location where META files are installed and\c removed (if the alternative layout is used).\c
stdlib\c
Prints the location of the standard library.\c
ldconf\c
Prints the location of the ld.conf file\c

THE SUBCOMMAND CALLING PACKAGE PROGRAMS

Synopsis

ocamlfind \c
pkg\c
/\c
cmd\c
 \c
argument\c
 ...\c

Description

This subcommand is useful to call programs that are installed in\c package directories. It looks up the directory for pkg\c and calls the command named\c cmd\c in this directory. The remaining arguments\c are passed to this command.\c
argv(0) contains the absolute path to the command, and argv(1) and\c the following argv entries contain the arguments. The working directory\c is not changed.\c
Example: To call the program "x" that is installed in package "p",\c with arguments "y" and "z", run:\c
ocamlfind p/x y z\c

CONFIGURATION FILE, ENVIRONMENT VARIABLES

The configuration file and environment variables are documented\c in the manual page for\c findlib.conf\c .\c

HOW TO SET THE TOOLCHAIN

Synopsis

ocamlfind -toolchain \c
name\c
 ...\c

Description

The -toolchain option can be given before any other command,\c e.g.\c
ocamlfind -toolchain foo ocamlc -c file.ml\c
compiles file.ml with toolchain "foo". By selecting toolchains one\c can switch to different command sets. For instance, the toolchain\c "foo" may consist of a patched ocamlc compiler. See findlib.conf\c how to\c configure toolchains.\c