|
NAMEocamlc - The OCaml bytecode compilerSYNOPSISocamlc [ options ] filename ...ocamlc.opt [ options ] filename ... DESCRIPTIONThe OCaml bytecode compiler ocamlc(1) compiles OCaml source files to bytecode object files and links these object files to produce standalone bytecode executable files. These executable files are then run by the bytecode interpreter ocamlrun(1).The ocamlc(1) command has a command-line interface similar to the one of most C compilers. It accepts several types of arguments and processes them sequentially, after all options have been processed: 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 ocamlc(1) compiler produces a compiled interface in the file x.cmi. 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 ocamlc(1) compiler produces compiled object bytecode in the file x.cmo. If the interface file x.mli exists, the implementation x.ml is checked against the corresponding compiled interface x.cmi, which is assumed to exist. If no interface x.mli is provided, the compilation of x.ml produces a compiled interface file x.cmi in addition to the compiled object code file x.cmo. The file x.cmi produced corresponds to an interface that exports everything that is defined in the implementation x.ml. Arguments ending in .cmo are taken to be compiled object bytecode. These files are linked together, along with the object files obtained by compiling .ml arguments (if any), and the OCaml standard library, to produce a standalone executable program. The order in which .cmo 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.cmo file must come before all .cmo files that refer to the unit x. Arguments ending in .cma are taken to be libraries of object bytecode. A library of object bytecode packs in a single file a set of object bytecode files (.cmo files). Libraries are built with ocamlc -a (see the description of the -a option below). The object files contained in the library are linked as regular .cmo files (see above), in the order specified when the .cma file 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 if the -custom flag is set (see the description of -custom below). Arguments ending in .o or .a are assumed to be C object files and libraries. They are passed to the C linker when linking in -custom mode (see the description of -custom below). Arguments ending in .so are assumed to be C shared libraries (DLLs). During linking, they are searched for external C functions referenced from the OCaml code, and their names are written in the generated bytecode executable. The run-time system ocamlrun(1) then loads them dynamically at program start-up time. The output of the linking phase is a file containing compiled bytecode that can be executed by the OCaml bytecode interpreter: the command ocamlrun(1). If caml.out is the name of the file produced by the linking phase, the command ocamlrun caml.out arg1 arg2 ... argn executes the compiled code contained in caml.out, passing it as arguments the character strings arg1 to argn. (See ocamlrun(1) for more details.) On most systems, the file produced by the linking phase can be run directly, as in: ./caml.out arg1 arg2 ... argn. The produced file has the executable bit set, and it manages to launch the bytecode interpreter by itself. ocamlc.opt is the same compiler as ocamlc, but compiled with the native-code compiler ocamlopt(1). Thus, it behaves exactly like ocamlc, but compiles faster. ocamlc.opt may not be available in all installations of OCaml. OPTIONSThe following command-line options are recognized by ocamlc(1).
SEE ALSOocamlopt(1), ocamlrun(1), ocaml(1).The OCaml user's manual, chapter "Batch compilation". Visit the GSP FreeBSD Man Page Interface. |