package linkage
Not available on OCaml 5.5Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=db21fe5e772025fa187d163f7555765335cf00d3c0cfe45d3798a2aebf5cbd03
md5=b3b9cd290a0b5710226d1068a67c752f
Description
Linkage provides an easier-to-use interface to OCaml's Dynlink module, so that plugins can be loaded into an application without having to use side-effects to register the plugin.
Added to opam-repository:
README
Linkage - easier plugin loading for OCaml
Linkage provides an easy way for OCaml programs to dynamically load plugins. (Internally, Linkage uses OCaml's standard Dynlink module).
You specify the type your plugin provides by extending Linkage's plugin type. Here, we're defining a plugin which provides a single string -> int function:
type Linkage.plugin += MyPlugin of (int -> string)The plugin is an ordinary OCaml module, which ends with a call to Linkage.provide:
let f = ...
...
Linkage.provide (MyPlugin f)The main application then uses Linkage.load to load the plugin (here with only minimal error handling):
let f =
match Linkage.load "plugins/plugin.cma" with
| Ok (MyPlugin f) -> f
| e -> Linkage.raise_error eThe plugin type (the Linkage.plugin += line) should be in a module by itself, since both the main application and the plugin depend on it. Only the main application and not the plugin should link against this module, to ensure that there's only one copy. If using OCamlbuild, you do this by omitting it from the plugin's .mllib file.
There are some working examples in the examples/ directory.
Dependencies (4)
-
topkg
build & >= "0.7.4" -
ocamlfind
build -
ocamlbuild
build -
ocaml
>= "4.03.0" & < "5.0.0"
Dev Dependencies
None
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building linkage with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.1 (this version) | good | good | n/a | n/a | n/a |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure