[Mono-dev] C++ code as Internal call
Zac Bowling
zac at zacbowling.com
Fri Jun 9 00:00:00 EDT 2006
Yah,
After to you read that article there is a niche with p/invoking C++.
You can't safely invoke into C++ libraries unless the functions you want
are exported as C functions (using "extern 'C' {...}"). The vtable and
name mangling differences between each C++ compiler (since they are not
standardized except on IA64 platforms) make this a very very complicated
and ultimately unmaintainable to make part of pinvoke it self (I know, I
tried :-P). There are a few tricks to make it work it on static
functions that only work on one compiler at a time (using the entry
point argument), but they are very dangerous and will break very easily.
So if the library you want to call doesn't provide standard C exports on
its own, then the best solution is write a wrapper library in C++ that
does.
Hope that helps.
----
Zac Bowling
http://zacbowling.com
On Thu, 2006-06-08 at 01:35 +0200, Zoltan Varga wrote:
> Hi,
>
> Read this, especially the section "Invoking Unmanaged Code":
>
> http://www.mono-project.com/Interop_with_Native_Libraries
>
> Zoltan
>
> On 6/8/06, Rusmin Susanto <rusminsusanto at yahoo.com> wrote:
> >
> > As far as I know, Mono is written in C. Internal calls are also written in
> > C. If I have a cool library/package that is written in C++, how do I define
> > it in Mono without having to re-write the library/package in C? I've tried
> > this few times but it seems that it's not working with g++.
> >
> >
> >
> > Regards
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
> >
> >
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
--
Zac Bowling <zac at zacbowling.com>
More information about the Mono-devel-list
mailing list