These SQLite bindings are broken in that they don't install the .so stub library. I modified the makefile to fix that and now they link ok, but then they segfault if I ever do anything wrong.
After some digging:
(gdb) r Starting program: /home/martine/oc/ocaml-sqlite/a.out Program received signal SIGSEGV, Segmentation fault. 0x10004a00 in raise_sqlite_error (zErrmsg=0x1005af60 "") at sqlite_stubs.c:171 171 raise_with_arg(*caml_named_value("sqlite error"), msg); \
it appears that the exceptions are not getting registered before the C stub tries to use them.
The library includes a .ml file that defines and registers the exceptions:
exception Sqlite_error of string
...
let _ = Callback.register_exception "sqlite error" (Sqlite_error "Registering Callback")
So maybe that code isn't getting ran?
If I use their toplevel, it properly runs my test program and raises an exception.
The .cmxa is linked like this:
ocamlmklib -o sqlite sqlite.cmx sqlite_stubs.o -lsqlite -oc sqlite_stubs -cclib -L.
So I want to think that the .cmx is getting linked in "first", whatever that may mean.
To reproduce this I'm linking with ocamlopt sqlite.cmxa test2.ml, but doing it the "right" way with findlib is equally broken.
Looking around at database wrappers led me to SKS, a PGP keyserver (one of the authors is the guy who did the OCaml Berkeley database wrappers) and to their paper Practical Set Reconciliation, which was tonight's reading. The original paper that provided BASIC-RECON would probably be worth reading, too.