Linux command
ocamlfind 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Compile with package
ocamlfind ocamlc -package [str] -linkpkg [program.ml] -o [program]
Compile native with packages
ocamlfind ocamlopt -package [core,yojson] -linkpkg [program.ml] -o [program]
List installed packages
ocamlfind list
Show package info
ocamlfind query [package]
Show package directory
ocamlfind query -d [package]
Show package dependencies
ocamlfind query -r [package]
Install package
ocamlfind install [package] META [*.cmi] [*.cmo] [*.cma]
Remove package
ocamlfind remove [package]
说明
ocamlfind is the package manager for OCaml libraries. It locates installed packages and configures compiler invocations automatically. The tool wraps OCaml compilers, adding include paths and library references based on package specifications. This simplifies builds by handling library dependencies. Each package has a META file describing its components, dependencies, and locations. Query commands extract this information for build systems and scripts. Package installation places libraries in a central repository with META files. This standardized layout enables reliable discovery and linking. Dependencies are resolved transitively. Specifying a high-level package automatically includes its prerequisites. Integration with build systems like Dune is common. Many projects use ocamlfind directly or through wrapper tools.
参数
- ocamlc _ARGS_
- Run bytecode compiler.
- ocamlopt _ARGS_
- Run native compiler.
- query _PKG_
- Query package information.
- list
- List installed packages.
- install _PKG_ _FILES_
- Install package.
- remove _PKG_
- Remove package.
- -package _PKGS_
- Packages to use (comma-separated).
- -linkpkg
- Link packages into executable.
- -predicates _PREDS_
- Set predicates.
- -syntax _SYNTAX_
- Set syntax extension.
- -d
- Show package directory.
- -r
- Recursive dependencies.
FAQ
What is the ocamlfind command used for?
ocamlfind is the package manager for OCaml libraries. It locates installed packages and configures compiler invocations automatically. The tool wraps OCaml compilers, adding include paths and library references based on package specifications. This simplifies builds by handling library dependencies. Each package has a META file describing its components, dependencies, and locations. Query commands extract this information for build systems and scripts. Package installation places libraries in a central repository with META files. This standardized layout enables reliable discovery and linking. Dependencies are resolved transitively. Specifying a high-level package automatically includes its prerequisites. Integration with build systems like Dune is common. Many projects use ocamlfind directly or through wrapper tools.
How do I run a basic ocamlfind example?
Run `ocamlfind ocamlc -package [str] -linkpkg [program.ml] -o [program]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does ocamlc _ARGS_ do in ocamlfind?
Run bytecode compiler.