I have a large OCaml project which I am compiling with ocamlbuild. Everything works fine, I have a great executable which does everything as I want. The problem is that when I take that native executable "my_prog.native" and run it somewhere else (different machine with same operating system, etc.), the new machine complaints that it can't find camomile (which is used in a Batteries library I'm using). I thought the executable we got from ocamlbuild was standalone and didn't require OCaml or Camomile to be present in the machine we ran it, but开发者_如何转开发 that doesn't seem to be the case.
Any ideas on how to produce really standalone executables?
Most OCaml code is statically linked. There are two things which are linked dynamically:
- C stub libraries when using bytecode (and possibly native code, although I do not think this is the case). These are
dllfoo.so
, corresponding tolibfoo.a
. If you have alibfoo.a
, I think it will use that rather thandllfoo.so
for native code. - Dynamic libraries depended on by the runtime or stub libraries (such as
libc
, orlibgtk
used bylablgtk
, etc.).
Further, Camomile dynamically loads some of its Unicode data, which is a special case that does not fall into standard OCaml linking. You'll have to consult the Camomile documentation to find a way to statically embed that data.
To the best of my knowledge, Camomile is dynamically loaded at runtime, so the easiest thing to do would be to provide the DLL/shared object along with your executable.
You could try forcing a static link, but this would contaminate your application with the LGPL license.
精彩评论