linkage

easier plugin loading
README

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 e

The 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.

Install
Published
10 Jan 2017
Sources
v0.1.tar.gz
md5=b3b9cd290a0b5710226d1068a67c752f
Dependencies
topkg
build & >= "0.7.4"
ocaml
>= "4.03.0"
Reverse Dependencies