4 ocamlc \- The Objective Caml bytecode compiler
37 The Objective Caml bytecode compiler
39 compiles Caml source files to bytecode object files and link
40 these object files to produce standalone bytecode executable files.
41 These executable files are then run by the bytecode interpreter
46 command has a command-line interface similar to the one of
47 most C compilers. It accepts several types of arguments and processes them
50 Arguments ending in .mli are taken to be source files for
51 compilation unit interfaces. Interfaces specify the names exported by
52 compilation units: they declare value names with their types, define
53 public data types, declare abstract data types, and so on. From the
58 compiler produces a compiled interface
62 Arguments ending in .ml are taken to be source files for compilation
63 unit implementations. Implementations provide definitions for the
64 names exported by the unit, and also contain expressions to be
65 evaluated for their side-effects. From the file
69 compiler produces compiled object bytecode in the file
74 exists, the implementation
76 is checked against the corresponding compiled interface
78 which is assumed to exist. If no interface
80 is provided, the compilation of
82 produces a compiled interface file
84 in addition to the compiled object code file
89 corresponds to an interface that exports everything that is defined in
93 Arguments ending in .cmo are taken to be compiled object bytecode. These
94 files are linked together, along with the object files obtained
95 by compiling .ml arguments (if any), and the Caml Light standard
96 library, to produce a standalone executable program. The order in
97 which .cmo and.ml arguments are presented on the command line is
98 relevant: compilation units are initialized in that order at
99 run-time, and it is a link-time error to use a component of a unit
100 before having initialized it. Hence, a given
102 file must come before all .cmo files that refer to the unit
105 Arguments ending in .cma are taken to be libraries of object bytecode.
106 A library of object bytecode packs in a single file a set of object
107 bytecode files (.cmo files). Libraries are built with
109 (see the description of the
111 option below). The object files
112 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
113 contained in a library is not referenced anywhere in the program, then
116 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
118 flag is set (see the description of
122 Arguments ending in .o or .a are assumed to be C object files and
123 libraries. They are passed to the C linker when linking in
125 mode (see the description of
130 is the same compiler as
132 but compiled with the native-code compiler
134 Thus, it behaves exactly like
138 is not available in all installations of Objective Caml.
142 The following command-line options are recognized by
147 Build a library (.cma file) with the object files (.cmo files) given on the command line, instead of linking them into an executable
148 file. The name of the library can be set with the
150 option. The default name is
155 Compile only. Suppress the linking phase of the
156 compilation. Source code files are turned into compiled files, but no
157 executable file is produced. This option is useful to
158 compile modules separately.
161 .BI \-cclib\ -l libname
164 option to the C linker when linking in
165 ``custom runtime'' mode (see the
167 option). This causes the
168 given C library to be linked with the program.
172 Pass the given option to the C compiler and linker, when linking in
173 ``custom runtime'' mode (see the
175 option). For instance,
178 causes the C linker to search for C libraries in
184 Link in ``custom runtime'' mode. In the default linking mode, the
185 linker produces bytecode that is intended to be executed with the
186 shared runtime system,
188 In the custom runtime mode, the
189 linker produces an output file that contains both the runtime system
190 and the bytecode for the program. The resulting file is larger, but it
191 can be executed directly, even if the
194 installed. Moreover, the ``custom runtime'' mode enables linking Caml
195 code with user-defined C functions.
199 Cause the compiler to print all defined names (with their inferred
200 types or their definitions) when compiling an implementation (.ml
201 file). This can be useful to check the types inferred by the
202 compiler. Also, since the output follows the syntax of interfaces, it
203 can help in writing an explicit interface (.mli file) for a file: just
204 redirect the standard output of the compiler to a .mli file, and edit
205 that file to remove all declarations of unexported names.
209 Add the given directory to the list of directories searched for
210 compiled interface files (.cmi) and compiled object code files
211 (.cmo). By default, the current directory is searched first, then the
212 standard library directory. Directories added with
215 after the current directory, in the order in which they were given on
216 the command line, but before the standard library directory.
220 Specify the name of the output file produced by the linker. The
221 default output name is
223 in keeping with the Unix tradition. If the
225 option is given, specify the name of the library produced.
229 Print the version number of the compiler.
233 Turn bound checking off on array and string accesses (the
237 constructs). Programs compiled with
240 slightly faster, but unsafe: anything can happen if the program
241 accesses an array or string outside of its bounds.
247 .I The Objective Caml user's manual,
248 chapter "Batch compilation".