[Mono-list] Managed C++ assemblies and Mono
Patrick Hartling
patrick@vrac.iastate.edu
Wed, 08 Jan 2003 16:41:08 -0600
Sergey Chaban wrote:
>>As long as it is only the initialization code, the few routines that are
>>used can be faked, so that should be no problem.
>
>
> I think the problem here is finding managed entry point.
> Say, C++ compiler generates _mainCRTStartup() entry, this is embedded
> x86 code, how would you find managed entry without interpreting mainCRTStartup?
> You can't rely on the naming, because even though managed entry for MC++ would
> be called "main", it's just a convention - some .NET obfuscators already replace
> this with something else. Well, unless I'm missing something :-)
For my case, I am worried more about the "entry point" into the native
library. That is, within a Managed C++ wrapper class, any calls made to
heap-allocated instances of unmanaged C++ code. That is where the
problems occur.
> BTW, to produce pure IL from C++ code the following options needed for the linker
> (assuming that -clr option is already used for the compiler):
> $link -nodefaultlib -entry:main mscoree.lib
Thanks, I'll check the options being used when the assembly is linked.
> But anyway original question was about using MC++ to interact with C++ libs compiled
> to _native_ code, if I understood the post correctly. I think in such case a C interface and
> P/Invoke would be a much better choice.
I would agree that for a native C interface (e.g., GTK+), that would be
better. From what I have seen of P/Invoke, however, it seems undesirable
for use with a C++ API due to all the static methods. What it really
comes down to is that I want to write a class in C# that implements an
interface defined in unmanaged C++. An instance of the C# class would be
passed through to unmanaged C++ code. There are a lot of details
involved with this, but the inherent object-oriented nature does not seem
to lend itself well to the structure of P/Invoke-style code.
-Patrick
--
Patrick L. Hartling | Research Assistant, VRAC
patrick@vrac.iastate.edu | 2624 Howe Hall: 1.515.294.4916
http://www.137.org/patrick/ | http://www.vrac.iastate.edu/