[Mono-list] C# in C++ using Mono
Tue, 6 Apr 2004 10:56:42 +0100
On Monday 05 April 2004 5:26 pm, email@example.com wrote:
> We have a C# application that has been developed in Visual studio on
> windows by another department in our company and we would like to use it in
> our C++ application on solaris SPARC environment. I've checked your website
> and it seems like Mono solves our problem. My question is if it is possible
> to recompile the C# application in Mono and use that class in our C++
> application (without Mono)?
Depends what you mean by 'without mono'. What it sounds like you are after if
a C# -> native code compiler which, AFAIK, isn't available anywhere yet [cf
the gcj Java -> native code compiler]. OTOH it is perfectly possible to embed
the mono runtime in your C++ app. This means from the PoV of an 'end-user'
they just run your app and are none the wiser.
I assume that the reason you don't want to include mono is related to
licensing? The runtime itself is licensed under the LGPL which means,
effectively, you can link to it in your propriety programs without fearing
the wrath of RMS (cf SDL & Linux games such as UT2004).
If it is relaterd to performance I don't think you have to worry. For me at
least the performance of mono has been superb, and the JIT seems just as fast
as compiled C (/very/ unscientific benchmarks performed on a proof-of-concept
port of part of my PhD). The startup latency is unmeasurable to my eyes. I
suspect its below the critical 0.7s :).
> In the FAQ page on question 3 you talk about <<
> This means for example that if you define a class to do algebraic
> manipulation in C#, that class can be reused from any other language that
> supports the CLI. You could create a class in C#, subclass it in C++ and
> instantiate it in an Eiffel program.
The key here is 'language that supports the CLI', i.e. it needs to be ported
or modified to use the CLI runtime to do its 'dirty work'. There were some
perl bindings posted a while back on the list in reply to my own post which
contained something similar for Perl.
> Does it also mean you can create a class in C#, subclass it in C++ and call
> the functions in the C# class from the C++ application?
Again only in supported languages. Microsoft has 'managed C++', their
propriety hack on top of C++ to achieve this. I don't know if there are
similar efforts to produce a hacked gcc.