ocamlfind query [-help | other options] package_name ... or: ocamlfind ocamlc [-help | other options] file ... or: ocamlfind ocamlcp [-help | other options] file ... or: ocamlfind ocamlmktop [-help | other options] file ... or: ocamlfind ocamlopt [-help | other options] file ... or: ocamlfind install [-help | other options] package_name file ... or: ocamlfind remove [-help | other options] package_name or: ocamlfind guess package_name file ... or: ocamlfind list or: ocamlfind printconf
ocamlfind query [ -predicates p | -format f | -long-format | -i-format | -l-format | -a-format | -o-format | -prefix p | -separator s | -suffix s | -descendants | -recursive ] package ...
This command looks packages up, sorts them optionally, and prints attributes of them. If the option -recursive is not specified, exactly the packages given on the command line are looked up; if -recursive is present, the packages and all their ancestors, or if -descendants is present, too, all their descendants are printed.
Package lookup and the selection of the attributes of the packages can be modified by specifying predicates; without a -predicates option the empty set of predicates is used. Note that even the lookup is influenced by the set of actual predicates as the "requires" variables may be conditional.
What is printed about a package depends on the specified format; there are a number of options that modify the format. Some formats denote sets of values (such as -format %a), in which case multiple output records are printed for every package. (It is even possible to specify formats denoting the Cartesian product of sets, such as -format %a%o, but this does not make sense.) Before the first output record the prefix is printed, and the suffix after the last record. Between two records the separator is printed.
Sets the set of actual predicates. The argument p is a list of predicate names separated by commas and/or whitespace. If multiple -predicates options are given, the union of all specified sets is effectively used.
Sets the format to the string f. Characters preceded by a percent sign are interpreted as placeholders; all other characters mean themselves. The defined placeholders are listed below. The default format is "%d".
Sets the format such that all relevant variables are printed.
Same as -format "-I %d", i.e. directory options for ocamlc are printed.
Same as -format "-ccopt -L%d", i.e. directory options for the linker backend are printed.
Same as -format "%a", i.e. archive file names are printed.
Same as -format "%o", i.e. linker options are printed.
Sets the prefix that is printed before the first output record to the given string. The default prefix is the empty string.
Sets the suffix that is printed after the last output record to the given string. The default suffix is the empty string.
Sets the separator that is printed between output records to the given string. The default separator is a linefeed character.
Not only the packages given on the command line are queried but also all ancestors or descendants. If the option -descendants is specified, too, the descendants are printed, otherwise the ancestors. The packages are topologically sorted.
This option has only an effect if -recursive is turned on, too. In this case, instead of the ancestors the descendants of the given packages are queried.
Replaced by the package name
Replaced by the package directory
Replaced by the version string
Replaced by the archive filename. If there is more than one archive, a separate output record is printed for every archive.
Replaced by the list of archive filenames.
Replaced by one linker option. If there is more than one option, a separate output record is printed for every option.
Replaced by the list of linker options.
ocamlfind ( ocamlc | ocamlcp | ocamlopt | ocamlmktop ) [ -package package-name-list | -linkpkg | -predicates pred-name-list | -dontlink package-name-list | -passopt arg | standard-option ] file ...
These subcommands are drivers for the compilers with the same names, i.e. "ocamlfind ocamlc" is a driver for "ocamlc", and so on. The subcommands understand all documented options of the compilers (here called standard-options), but also a few more options. If these subcommands are invoked only with standard options, they behave as if the underlying compiler had been called directly. The extra options modify this.
Internally, these subcommands transform the given list of options and file arguments into an invocation of the driven compiler. This transformation only adds options and files, and the relative order of the options and files passed directly is unchanged.
If there are -package options, additional directory search specifiers will be included ("-I", and "-ccopt -I"), such that files of all named packages and all ancestors can be found.
The -linkpkg option causes that the packages listed in the -package options and all necessary ancestors are linked in. This means that the archive files implementing the packages are inserted into the list of file arguments.
As the package database is queried a set of predicates is needed. Most predicates are set automatically, see below, but additional predicates can be given by a -predicates option.
Here, only the additional options not interpreted by the compiler but by the driver itself, and options with additional effects are explained.
Adds the listed package names to the set of included packages. The package names may be separated by commas and/or whitespace. In the transformed command, for every package of the set of included packages and for any ancestor a directory search option is inserted after the already given options. This means that "-I" and "-ccopt -I" options are added for every package directory.
Causes that in the transformed command all archives of the packages specified by -packages and all their ancestors are added to the file arguments. More precisely, these archives are inserted before the first given file argument. Furthermore, "-ccopt -L" options for all package directories, and the linker options of the selected packages are added, too. Note that the archives are inserted in topological order while the linker options are added in reverse toplogical order.
Adds the given predicates to the set of actual predicates. The predicates must be separated by commas and/or whitespace.
This option modifies the behaviour of -linkpkg. Packages specified here and all ancestors are not linked in. Again the packages are separated by commas and/or whitespace.
The argument arg is passed directly to the underlying compiler. This is needed to specify undocumented compiler options.
This standard option is interpreted by the driver, too.
This standard option causes that the predicate "mt" is added to the set of actual predicates.
This standard option of "ocamlopt" causes that the predicate "gprof" is added to the set of actual predicates.
The "byte" predicate means that one of the bytecode compilers is used. It is automatically included into the predicate set if the "ocamlc", "ocamlcp", or "ocamlmktop" compiler is used.
The "native" predicate means that the native compiler is used. It is automatically included into the predicate set if the "ocamlopt" compiler is used.
The "toploop" predicate means that the toploop is available in the linked program. It is automatically included into the predicate set if the "ocamlmktop" compiler is used.
The "mt" predicate means that the program is multi-threaded. It is automatically included into the predicate set if the -thread option is given.
The "mt_posix" predicate means that in the case "mt" is set, too, the POSIX libraries are used to implement threads. "mt_posix" is automatically included into the predicate set if the variable "type_of_threads" in the META description of the "threads" package has the value "posix". This is normally the case if "findlib" is configured for POSIX threads.
The "gprof" predicate means that in the case "native" is set, too, the program is compiled for profiling. It is automatically included into the predicate set if "ocamlopt" is used and the -p option is in effect.
The "autolink" predicate means that ocamlc is able to perform automatic linking. It is automatically included into the predicate set if ocamlc knows automatic linking (from version 3.00), but it is not set if the -noautolink option is set.
As there is a special module Topfind[Module to load packages into toploops] that supports loading of packages in scripts, the "ocamlmktop" subcommand can add initialization code for this module. This extra code is linked in if "findlib" is in the set of effectively linked packages.
Normally, the O'Caml bytecode compiler can be called under the name ocamlc. However, this is not always true; sometimes a different name is chosen.
You can instruct ocamlfind to call executables with other names than ocamlc, ocamlopt, ocamlmktop, and ocamlcp. If present, the environment variable OCAMLFIND_COMMANDS is interpreted as a mapping from the standard names to the actual names of the executables. It must have the following format:
standardname1=actualname1 standardname2=actualname2 ...
Example: You may set OCAMLFIND_COMMANDS as follows:
OCAMLFIND_COMMANDS='ocamlc=ocamlc-3.00 ocamlopt=ocamlopt-3.00' export OCAMLFIND_COMMANDS
Alternatively, you can change the configuration file findlib.conf.
ocamlfind install [ -destdir directory ] [ -metadir directory ] [ -dont-add-directory-directive ] package_name file ...
This subcommand installs a new package either at the default location (see the variable destdir of findlib.conf), or in the directory specified by the -destdir option. This means that a new package directory is created and that the files on the command line are copied to this directory.
Note that package directories should be flat (no subdirectories). Existing packages are never overwritten.
It is possible to have a separate directory for all the META files. If you want that, you have either to set the variable metadir of findlib.conf, or to specify the -metadir option. In this case, the file called META is copied to the specified directory and renamed to META.p (where p is the package name), while all the other files are copied to the package directory as usual. Furthermore, the META file is modified such that the directory variable contains the path of the package directory.
The option -dont-add-directory-directive prevents the installer from adding a directory variable.
The package will removed if it is installed at the default location (see the variable destdir of findlib.conf). If the package resides at a different location, it will not be removed by default; however, you can pass an alternate directory for packages by the -destdir option. (This must be the same directory as specified at installation time.)
Note that package directories should be flat (no subdirectories); this subcommand cannot remove deep package directories.
If you have a separate directory for META files, you must either configure this directory by the metadir variable of findlib.conf, or by specifying the -metadir option.
The command does not fail if the package and/or the META file cannot be located.
This command is experimental: It tries to determine the META file by inspecting the files to install for a package, and by comparing these files with the current package base.
Simply call this command after you have built your library and before you want to install it for the first time. The first argument must be the package name, and the other arguments must be the files you are going to install. The command inspects the .cmi and .cma/.cmxa files and writes a META file to stdout. (Of course, it does not install any of these files.)
Note that the generated META file is guessed and may be wrong.