LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ocamlc

OCaml bytecode compiler

TLDR

Compile to bytecode
$ ocamlc -o [program] [source.ml]
copy
Compile multiple files
$ ocamlc -o [program] [file1.ml] [file2.ml]
copy
Compile with library
$ ocamlc -I +[library] [library].cma [source.ml] -o [program]
copy
Compile to object file
$ ocamlc -c [source.ml]
copy
Compile with debug info
$ ocamlc -g -o [program] [source.ml]
copy

SYNOPSIS

ocamlc [options] files...

DESCRIPTION

ocamlc is the OCaml bytecode compiler. It compiles OCaml source files to bytecode that runs on the OCaml virtual machine.For native code compilation with better performance, use ocamlopt instead.

PARAMETERS

-o file

Output filename.
-c
Compile only (no link).
-I dir
Add include directory.
-g
Include debug info.
-i
Print inferred types.
-a
Create library archive.
-linkall
Link all modules.

FILE EXTENSIONS

$ .ml   - Implementation
.mli  - Interface
.cmo  - Bytecode object
.cma  - Bytecode library
.cmi  - Compiled interface
copy

EXAMPLE

$ # Compile simple program
ocamlc -o hello hello.ml

# With standard library
ocamlc -I +str str.cma program.ml -o program
copy

INSTALL

sudo apt install ocaml
copy
sudo dnf install ocaml
copy
sudo pacman -S ocaml
copy
sudo apk add ocaml5
copy
sudo zypper install ocaml
copy
brew install ocaml
copy
nix profile install nixpkgs#ocaml
copy

CAVEATS

Bytecode slower than native. Link order matters. Use ocamlopt for production.

HISTORY

OCaml was developed at INRIA (French computing research institute), evolving from Caml Light. The bytecode compiler has been part of OCaml since its creation.

SEE ALSO

ocamlopt(1), dune(1), opam(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid