Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any examples of compiling C# code using Mono so that the exe can run with Google's native client support?

I have found a press release that states that Mono now support compilation for native client. It's unclear whether this is only available from the separate github mono fork, or as part of the standard distribution.

I've built the forked mono distribution, but I have been unable to find any examples on how to build a native client executable so that I can run it in Chrome.

Is anyone aware of an example project, or can you provide an example for how to build a Mono application for NaCl?

like image 660
Jeff Thompson Avatar asked Oct 27 '11 20:10

Jeff Thompson


People also ask

What is compiler in C with example?

compiler, computer software that translates (compiles) source code written in a high-level language (e.g., C++) into a set of machine-language instructions that can be understood by a digital computer's CPU. Compilers are very large programs, with error-checking and other abilities.

What is C compiling?

Compiling a C Program. Compiling is the transformation from Source Code (human readable) into machine code (computer executable). A compiler is a program.


3 Answers

I think some of the changes may have been upstreamed, but as of today (11/16/11) there are definitely bugfixes that are still only in the github fork ( https://github.com/elijahtaylor/mono/ ). To build mono for nacl, follow the instructions in the mono/nacl directory ( https://github.com/elijahtaylor/mono/tree/master/nacl ). You want the mono runtime, which will build a mono which can be embedded in your nacl module and can JIT-compile .NET assemblies. (There is also a mono AOT compiler which runs on linux/mac and generates nacl modules, but I'm pretty sure it doesn't work right now, as nobody is using or testing it).

See nacl/test/my.c and mono/mini/fsacheck.c for examples of how to call the mono runtime to JIT code from your nacl module. Inside the browser you'll have to come up with your own way (e.g. pepper and/or nacl-mounts) to get the bytcode into your nacl module.

like image 78
Derek Avatar answered Oct 04 '22 19:10

Derek


I'm not sure it's been up-streamed into the Mono repository, but there's a fork that runs on NaCl here : https://github.com/elijahtaylor/mono Note, use at your own risk!

like image 26
Colt McAnlis Avatar answered Oct 04 '22 20:10

Colt McAnlis


This post from March 2012 indicates that Chrome 19 has Native Client support for Embedded Mono

Versions of Mono for Native Client are now available for download in the SDK. These are compiled with glibc and the libmono comes as a dynamic library. Only pepper_19 and above has Mono available.

Note that you must keep your pepper_X and naclmono_X bundles in sync (ie, don't update one without updating the other) or you will probably be unable to run the resulting built nexes. New versions of Mono that match a given SDK should be available within hours of a new SDK build being available.

Only embedded Mono is supported in Native Client currently (http://www.mono-project.com/Embedding_Mono).

like image 43
Greg Bray Avatar answered Oct 04 '22 18:10

Greg Bray