Linux command
ocamlc 命令
文本
Copy it and replace filenames, paths, or keywords as needed.
命令示例
Compile to bytecode
ocamlc -o [program] [source.ml]
Compile multiple files
ocamlc -o [program] [file1.ml] [file2.ml]
Compile with library
ocamlc -I +[library] [library].cma [source.ml] -o [program]
Compile to object file
ocamlc -c [source.ml]
Compile with debug info
ocamlc -g -o [program] [source.ml]
说明
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.
参数
- -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.
FAQ
What is the ocamlc command used for?
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.
How do I run a basic ocamlc example?
Run `ocamlc -o [program] [source.ml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o _file_ do in ocamlc?
Output filename.