[Mono-dev] C++ wrapper ?

ivar at imaker.no ivar at imaker.no
Fri Sep 2 03:32:21 EDT 2005

If I want to wrap a c++ class library what should I do ?
For me it seems like I have to do the following:
1. Make a ANSI c interface file calling the C++ functions, interfacefile_1
2. use csharps DLLImport directive making a wrapper class i csharp,

But then I have still two problems
I. A lot of arguments and return values are of C++ std template types,
like vector, string etc.
II. I must create the object in c++ before I can start to use it.

A solution to both I and II is to make a simpler interface in C++ and
adding a init function whichs creates the original object when called,

So then the call stack looks like:
C++ class I want to use
C++ wrapper to simplify arguments, and to add a functrion for creation of
original class
c wrapper to become compatible with the c# DLL import directive
a c# wrapper using DLL import

I know it is possible to skip c wrapper file and using the callnames of
c++,  but since this is not compiler independent I prefer not to do it
this way.

So my question is: Is there no easier way to interface to c++ code ?
Had it only been one class I think I could have used swig, but I donæt see
how I can use swig when I have many C++ classes.
Best regards

More information about the Mono-devel-list mailing list