zshipko / ocaml-rust-starter

Getting started with ocaml-rs
ISC License
31 stars 4 forks source link

ocaml-rust-starter

An example project using ocaml-rs to call Rust functions from OCaml.

If you're looking for an example of linking an OCaml library into a Rust program take a look at rust-ocaml-starter

New project checklist

Many of the renaming steps can be automated using init.sh:

$ ./init.sh my_project my-project

init.sh accepts two arguments: the name of the OCaml project and the public_name, if they are the same then one argument is acceptable.

NOTE: init.sh is destructive and can only be executed once (it will remove itself) - make sure you have no modifications that you want to keep before running init.sh.

Building

dune build

to run the tests:

dune runtest

to load your library into an interactive sesssion:

OCAML_INTEROP_NO_CAML_STARTUP=1 dune utop

The OCAML_INTEROP_NO_CAML_STARTUP environment variable should be set to ensure the library is linked correctly.