Some time ago I emerged for myself that Guile and Racket can be embedded and be called right from any C++ application.
Can OCaml work like this?
You can have a look at the Embedded O'Caml Toplevel done by Clément Capel. It's the result of a summer internship so it wasn't updated since 2004.
Otherwise, there is ocamlmklib.
You can use the OCaml toplevel as a library. It is part of the official OCaml distribution and up-to-date. See toploop.mli in OCaml sources for the interface. It is officially only available in bytecode, but there is experimental support for native code.
If you plan to redistribute your application, be aware that the toplevel library (and the compiler itself) are under a more restrictive license (modified QPL) than the standard library and runtime (modified LGPL).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With