ocamlopt
Compile OCaml code to optimized native executables
TLDR
Compile a source file
Compile with debugging enabled
SYNOPSIS
ocamlopt [options] filenames
PARAMETERS
-a
Build a library. This is equivalent to specifying -output-obj and -pack.
-c
Compile only. Generate an object file but do not link.
-o
Set the name of the output file.
-I
Add
-g
Add debugging information for use with the ocamldebug debugger.
-v
Print the version number of the compiler.
-w
Enable or disable warnings according to .
-unsafe
Turn off bounds checking on array and string accesses.
OCaml source files (.ml) and compiled object files (.cmo, .cmx).
DESCRIPTION
ocamlopt
is the native-code compiler for the OCaml language. It translates OCaml source code into efficient machine code executables. Unlike the bytecode compiler (ocamlc
), ocamlopt
directly produces native code, resulting in significantly faster execution times for compiled programs. It supports various optimization techniques to improve the performance of the generated code.
The compilation process typically involves parsing the OCaml source files, type checking, generating intermediate code, performing optimizations, and finally producing the native code executable. ocamlopt
can also be used to create object files that can be linked with other code, including C code, to build more complex systems. Libraries and modules can be compiled separately and linked together.
When speed of execution is paramount, ocamlopt
is the preferred choice over ocamlc
, although the compilation process may take longer.
COMPILER FLAGS
ocamlopt
supports a wide variety of compiler flags to control optimization levels, code generation, and other aspects of the compilation process. Refer to the OCaml manual for a complete listing.
LINKING WITH C CODE
ocamlopt
can produce object files that can be linked with C code using a standard linker. This allows OCaml code to interact with existing C libraries and systems.
SEE ALSO
ocamlc(1), ocamldebug(1)