English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
how to call an OCaml library from C/C++ ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-08-24 (17:50)
From: Yoann Padioleau <padator@w...>
Subject: how to call an OCaml library from C/C++ ?

Is there a way to call OCaml library from a C/C++ program without the C++ program
knowing it's OCaml code ? I mean I can not touch the main of the C++ program
so it has to be completely transparent and it would be good if each call to the ocaml library
once finished free all the memory it was using.
Can we call  caml_startup() multiple times ? is there a caml_cleanup ?

Ideally I would like from C/C++ to have:

char* sanitize_stuff(char *s) {

  char * res = <call_ocaml_code_with_s>;
  return res;

and then link my c++ program with my_extension.o  and some .a containing ocaml code.