Using (ocaml-)ctypes to build a shared library involving structs of function pointers. See the thread on the ctypes mailing list for background.
Contents:
- bindings.ml, the inverted bindings themselves
- gen.ml, the code generator
- load.ml, which links the bindings with the generated code
- build.sh, the build script
- client.c, a client to test the library.
You'll need an OCaml distribution compile to position-independent code and the ctypes library. OPAM users can install the prerequisites by issuing the following commands:
opam switch 4.01.0+PIC
eval `opam config env`
opam install ctypes
Once everything's installed you can build the library and run the test as follows:
chmod +x build.sh
./build.sh
LD_LIBRARY_PATH=. ./client