[Mono-list] How to create C++ library and call it's functionsfrom C# program?

Vadim B. Guzev vguzev@yandex.ru
Fri, 12 Mar 2004 13:53:39 +0300

First of all, thanks!  I've added the 'extern "C"', removed 'static' keyword
and "using namespace std" lines, removed the "EntryPoint" and changed gcc to
It's working now :)

> Make sure that "libmylib.so" is in your LD_LIBRARY_PATH environment
> variable, so that the dynamic linker can find the library.
It's not necessary, as the library in the same path...

> I would suggest making sure that a "hello, world" C++ program correctly
> from the same directory and environment you're trying to run this
> program from.
When I use gcc it doesn't work, but with g++ works well.

> First off, what platform are you trying to do this on?
I'm using some kind of Linux clone (our guys from university created it from
RedHat sources, if I'm not mistaken...),
gcc 3.0.4, Mono 0.28 (I can't migrate to new versions of Mono because of bug
http://bugs.ximian.com/show_bug.cgi?id=53788 :-( )
Maybe these warning messages disappeared in new versions... I can't check it
for now..

> So I'll have to recommend my guide "Everything you (n)ever wanted to
> know about Marshalling (and were afraid to ask!)", available at:
> http://www.jprl.com/~jon/interop.html

Well, actually I've started investigating from your guide ;-)
Very good article! Although, I should recomend you to add some examples of
compiling C++ sources into libraries (it will be usefull for C# programmers,
who had never used C++ libraries before, but have to do it now for some
particlar reasons). I had to search a lot of Web sites to find this rules...

Best regards,
Vadim B. Guzev