A new frontend for ocamlc

The findlib User's Guide
Prev |  | Next

# Chapter 4. A new frontend for ocamlc

# Compiling and linking

There are compiler frontends for the four compilers ocamlc, ocamlopt, ocamlmktop, and ocamlcp. They are simply called by specifying the name of the compiler as first argument to ocamlfind, i.e.

    ocamlfind ocamlc ...arguments...
    ocamlfind ocamlopt ...arguments...
    ocamlfind ocamlmktop ...arguments...
    ocamlfind ocamlcp ...arguments...

In addition to the compiler options handled by the compilers themselves, the following options are available:

- -package <name>: Causes that the package <name> is added to the package list, and that -I options are added for every package, and all direct or indirect ancestors.

- -linkpkg: Causes that the archives of the packages in the package list and all their direct or indirect ancestors are added in topological order to the command line before the first file to compile or to link. Packages specified by -dontlink are not linked in, though. Furthermore, the linker options of these packages are added in reverse topological order at the end of the command line.

- -predicates <predicate-list>: The named predicates are included in the list of predicates. Note that there are some predicates set by default, see below.

- -dontlink <name>: Specifies that the package <name> and all its direct or indirect ancestors should not be linked in.

- -passopt <opt>: The option <opt> is passed directly to the underlying compiler. This is especially needed to pass undocumented options to the compiler.

If you only want to compile, i.e. the -c option is in effect, you normally only need the -package option.

Depending on the compiler and on the given options, some predicates are set by default:

- byte: The predicate "byte" is set when ocamlc, ocamlcp, or ocamlmktop is used to compile or link.

- native: The predicate "native" is set when ocamlopt is used to compile or to link.

- toploop: The predicate "toploop" is set when a toploop is being executed

- create_toploop: The predicate "toploop" is set when ocamlmktop is used to compile or to link a toploop

- gprof: The predicate "gprof" is set when ocamlopt with -p option is invoked.

- mt: The predicate "mt" is set when the -thread or the -vmthread option is in effect.

- mt_posix: The predicate "mt_posix" is set together with "mt" if the POSIX thread implementation is selected.

- mt_vm: The predicate "mt_vm" is set together with "mt" if the bytecode thread implementation is selected.

- autolink: The predicate "autolink" is set if the OCaml compiler can perform automatic linking. This predicate is never set if the -noautolink option is in effect.

Prev | Home | Next
Querying descendants | Up | Toploops and runtime systems