ocamlopt.opt (same options)
The ocamlopt(1) command has a command-line interface very close to that of ocamlc(1). It accepts the same types of arguments and processes them sequentially:
Arguments ending in .mli are taken to be source files for compilation unit interfaces. Interfaces specify the names exported by compilation units: they declare value names with their types, define public data types, declare abstract data types, and so on. From the file x.mli, the ocamlopt(1) compiler produces a compiled interface in the file x.cmi. The interface produced is identical to that produced by the bytecode compiler ocamlc(1).
Arguments ending in .ml are taken to be source files for compilation unit implementations. Implementations provide definitions for the names exported by the unit, and also contain expressions to be evaluated for their side-effects. From the file x.ml, the ocamlopt(1) compiler produces two files: x.o, containing native object code, and x.cmx, containing extra information for linking and optimization of the clients of the unit. The compiled implementation should always be referred to under the name x.cmx (when given a .o file, ocamlopt(1) assumes that it contains code compiled from C, not from Caml).
The implementation is checked against the interface file x.mli (if it exists) as described in the manual for ocamlc(1).
Arguments ending in .cmx are taken to be compiled object code. These files are linked together, along with the object files obtained by compiling .ml arguments (if any), and the Caml Light standard library, to produce a native-code executable program. The order in which .cmx and .ml arguments are presented on the command line is relevant: compilation units are initialized in that order at run-time, and it is a link-time error to use a component of a unit before having initialized it. Hence, a given x.cmx file must come before all .cmx files that refer to the unit x.
Arguments ending in .cmxa are taken to be libraries of object code. Such a library packs in two files lib.cmxa and lib.a a set of object files (.cmx/.o files). Libraries are build with ocamlopt -a (see the description of the -a option below). The object files contained in the library are linked as regular .cmx files (see above), in the order specified when the library was built. The only difference is that if an object file contained in a library is not referenced anywhere in the program, then it is not linked in.
Arguments ending in .c are passed to the C compiler, which generates a .o object file. This object file is linked with the program.
Arguments ending in .o or .a are assumed to be C object files and libraries. They are linked with the program.
The output of the linking phase is a regular Unix executable file. It does not need ocamlrun(1) to run.
ocamlopt.opt is the same compiler as ocamlopt, but compiled with itself instead of with the bytecode compiler ocamlc(1). Thus, it behaves exactly like ocamlopt, but compiles faster. ocamlopt.opt is not available in all installations of Objective Caml.
The following command-line options are recognized by ocamlopt(1).