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: Re: [Caml-list] how to call an OCaml library from C/C++ ?

On Aug 24, 2010, at 10:50 AM, Yoann Padioleau wrote:

> 
> 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;
> }

Also it is possible to have multiple independent ocaml runtime at the same time 
so such a function is thread-safe ?


> 
> and then link my c++ program with my_extension.o  and some .a containing ocaml code.
> 
> 
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>