Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1674401
  • 博文数量: 230
  • 博客积分: 10045
  • 博客等级: 上将
  • 技术积分: 3357
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-30 20:40
文章分类

全部博文(230)

文章存档

2011年(7)

2010年(35)

2009年(62)

2008年(126)

我的朋友

分类:

2008-08-01 21:21:23

ODLL

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.

Installation

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.

Usage

  • 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.
  • run 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.

Distribution

You can get a precompiled binary .

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:anonymous@cvs.motion-twin.com:/cvsroot login
(enter empty password)
cvs -d:pserver:anonymous@cvs.motion-twin.com:/cvsroot co ocaml/odll
阅读(1041) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~