If you're having a boss asking you to write C librairies but if you prefer to write them in OCaml, this tool is for you ! ODLL is creating a Win32 DLL from an OCaml library, and automatically generating the C stubs needed to interface the OCaml code and the C code and the .H interface. Simply run ODLL with you CMA/CMXA and one or several CMI interfaces and ODLL will do the job for you.
Since ODLL require one part of the OCaml sources, you'll need to get them from the INRIA CVS if you want to recompile ODLL. For convenience, a precompiled version is included in the distribution, which only require OCaml to be installed. You only need the odll.exe file to use odll. A sample is provided in the /sample directory.
- First, create an OCaml library (CMA or CMXA) using ocaml compilers (ocamlc or ocamlopt).
- Then, write one or several MLI interfaces for the OCaml functions you want to export into the DLL. Currently only the following basic ocaml types are supported : unit, int, float, string, char, bool and arrays.
- Compile your interfaces into CMI files using Ocamlc.
ODLL -o mylib.dll myfile.cm[x]a myintf1.cmi myintf2.cmi ...to create the DLL.
The following flags are provided :
- -header : generate a .H header file containing exported functions.
- -v : verbose mode, print commands run by ODLL.
- -keep : (debug only) do no delete intermediate files produced by ODLL.
- you can now write your C code using the DLL produced by ODLL, see the sample.c file for more informations.
You can get a precompiled binary here.
To access the sources of this project, you can check them out from CVS repository. This is recommanded since this way you'll be sure to get latest version with fixes. Use the following commands :
cvs -d:pserver:email@example.com:/cvsroot login (enter empty password) cvs -d:pserver:firstname.lastname@example.org:/cvsroot co ocaml/odll