I have wrapped a C library for use with Ocaml and didn't find
the task too daunting. I have now found a C++ library that would
be useful, but the Ocaml ORA book makes no mention of wrapping
C++ libraries.
Has anyone got any experience wrapping C++ libraries in Ocaml?
Is it possible? Painful but doable? Too painful to think about?
Any pointers or advice appreciated.
Cheers,
Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo
+-----------------------------------------------------------+
"I consider C++ the most significant technical hazard to the survival
of your project and do so without apologies." -- Alistair Cockburn
_______________________________________________
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
> Has anyone got any experience wrapping C++ libraries in Ocaml?
> Is it possible? Painful but doable? Too painful to think about?
>
>
I have done it a few times, it's much typing :-)
you must write a c function for the methods of the class you want to
wrap and give them a pointer to the c++ class, so you can call the
method there. Often you define on the c++ side an adapter class which
delegates method calls to the ocaml side (f.e. when wrapping events from
and to c++/ocaml). For big libraries it's a neverending task without
more tools.
There is the platinum framework (on sourceforge), a c++ class lib with a
little gui. This lib compiles for win32, Linux, WinCE and qnx, I have
done some wrapping to the gui part, together with the event handling and
it works very nice (if you want to read it as an example).
> Any pointers or advice appreciated.
>
>
Python, Ruby and Perl all have wrappers for QT and they use tools to
generate the C interface I think. Maybe worth to look at...
cheers,
Michael
> Has anyone got any experience wrapping C++ libraries in Ocaml?
> Is it possible? Painful but doable? Too painful to think about?
>
> Any pointers or advice appreciated.
Swig?
- Dmitry Bely
I did it some time ago, and I wrote a small tutorial about it :
http://www-sop.inria.fr/everest/personnel/Anne.Pacalet/camltop.php
Unfortunatly for you, it is in french, but maybe it can help anyway...
It explains both how to call C++ for caml and to call ocaml from C++.
Hope this will help.
Anne.