You need to
add the
linkall
flag tomain
, otherwise it will remove parts of the OCaml runtime that will later be needed by dynamic pluginscompile the
gtk_plugin.cmxs
file with option-lflag lablgtk.cma
(which I deduced from seeing in the_log
that this option was not passed)
The way ocamlbuild deduces .cmxs
dependencies is not optimal right now, and it's hard because different users may want different things (minimal plugins assuming libs are present, or on the contrary portable statically linked stuff). For modules coming from your project you can write a foo.mldylib
file to be explicit about what you want excluded, but I don't know whether it's possible to include "all modules of this external library".
Note that it is also possible to distribute lablgtk.cmxs
and the relevant .cmi
along with your plugin, and load it dynamically first.
mkdir lablgtk
cp `ocamlfind query lablgtk2`/lablgtk.cmxs lablgtk
cp `ocamlfind query lablgtk2`/*.cmi lablgtk
echo "\"lablgtk\": not_hygienic" >> _tags
then in your main.ml
let () =
try
Dynlink.loadfile "lablgtk/lablgtk.cmxs";
Dynlink.loadfile "_build/gtk_plugin.cmxs"
...