Using OCaml 4.12.0 for Windows (Cygwin-64 on Windows), I was able to get sqlite3-ocaml bindings working just fine. I was also able to create a sample OCaml sqlite3 application similar to [1].
For my OCaml sqlite3 application to work β the program needs access to sqlite3.dll, or in my case I had to rename it to libsqlite3-0.dll. However, my requirement is to deploy a single exe rather than the exe and the sqlite3 DLL.
Question: Is it possible to compile/link my OCaml program with sqlite3 so that the sqlite library is linked into the OCaml exe? Therefore I do not require a separate DLL file in my distribution.
I am able to create the sqlite3 DLL from source on Windows (Cygwin-64) [2]. My guess is I need to link the sqlite3 library with to my OCaml application.
Any input/hints would be greatly appreciated.
Many Thanks
Yes, this is possible and not very difficult: sqlite is distributed as a single .c file. To do what you want, you can either
compile this single .c file as part of your C stubs, or
compile this single .c file into a static library and link to it.
If using dune, 1) is done using the (foreign_stubs ...) field, and 2) is done using (foreign_library ...) stanza (to build the library) + (foreign_archives ...) field to link to it.
If you are not using Dune you can just compile sqlite into an object file (gcc -c) or static library and pass it on the command-line of ocamlopt that links your executable.