English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
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: -- (:)
From: Yoann Padioleau <padator@w...>
Subject: how to call an OCaml library from C/C++ ?
Hi,

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:


my_extension.c:
char* sanitize_stuff(char *s) {

  caml_startup();
  char * res = <call_ocaml_code_with_s>;
  caml_cleanup();
  return res;
}

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