Mono: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
Line 9: Line 9:
To write an OLPC Mono activity, you need to prepare a .xo [[Bundle]] including all required libraries. This is necessary because the Mono runtime is not officially supported by the OS images.
To write an OLPC Mono activity, you need to prepare a .xo [[Bundle]] including all required libraries. This is necessary because the Mono runtime is not officially supported by the OS images.


If you use mono, you know that the compiler not traslate the source code to the assembly language, but in IL (Intermediate Language) that need a runtime to be run. Since you don't have the runtime installed on the XO, you need to create a mono bundle so all the runtime is packed in one executable.
If you use Mono, you know that the C# compiler does not traslate the source to machine code, but to an IL (Intermediate Language) that requires a runtime to be executed. Since you don't have the runtime installed on the XO, you need to create a Mono bundle so the runtime is packed with the executable.


To do this you need to have the program already in binary format and use the mkbundle2 utility to create the stand-alone application.
To do this, you need to have the program already in binary format and use the mkbundle2 utility to create the stand-alone application.


mkbundle2 --config /etc/mono/config --deps --static -o MonkeysMemory.exe monkeysmemory.exe Sugar_0.0.1.dll NDesk.DBus.GLib.dll NDesk.DBus.dll
mkbundle2 --config /etc/mono/config --deps --static -o MonkeysMemory.exe monkeysmemory.exe Sugar_0.0.1.dll NDesk.DBus.GLib.dll NDesk.DBus.dll


In this example "monkeysmemory.exe" is the original binary file that use the IL (Intermediate Language), while "MonkeysMemory.exe" is the binary file that can be run without runtime installed.
In this example "monkeysmemory.exe" is the original IL binary file, while "MonkeysMemory.exe" is the binary file that can be run without runtime installed.


Normally the use of --static flag have some licence restriction, but here can be use without limitation.
Normally, using the --static flag has some licence restriction, but here it can be used without limitation.


In your bundle you need to put some glue shared library that are used by Mono runtime like this:
In your bundle you need to put some glue shared libraries that are used by the Mono runtime like this:


* libgdksharpglue-2.so
* libgdksharpglue-2.so
Line 29: Line 29:
* uiX11Util.so
* uiX11Util.so


All this files (except uiX11Util.so) are taken from mono environment. The latest (uiX11Util.so) is specific for OLPC and allow to setup some X11 parameter need to sugar interface.
All these files (except uiX11Util.so) are taken from mono environment. The last one (uiX11Util.so) is
OLPC specific and allows to setup some X11 atoms needed by the Sugar interface.
This files are placed in the bin directory of the activity.
These files are placed in the bin directory of the activity.


=How to run a Mono activity=
=How to run a Mono activity=

Revision as of 21:21, 28 December 2007

This article is a stub. You can help the OLPC project by expanding it.

Sugar activities are usually written in Python using the Python Activity API. This page documents how it is possible to use Mono to write a Sugar activity. With Mono, you can use any underlying language like C# or Boo.

Overview

XO Bundle and Mono Bundle

To write an OLPC Mono activity, you need to prepare a .xo Bundle including all required libraries. This is necessary because the Mono runtime is not officially supported by the OS images.

If you use Mono, you know that the C# compiler does not traslate the source to machine code, but to an IL (Intermediate Language) that requires a runtime to be executed. Since you don't have the runtime installed on the XO, you need to create a Mono bundle so the runtime is packed with the executable.

To do this, you need to have the program already in binary format and use the mkbundle2 utility to create the stand-alone application.

mkbundle2 --config /etc/mono/config --deps --static -o MonkeysMemory.exe monkeysmemory.exe Sugar_0.0.1.dll NDesk.DBus.GLib.dll NDesk.DBus.dll

In this example "monkeysmemory.exe" is the original IL binary file, while "MonkeysMemory.exe" is the binary file that can be run without runtime installed.

Normally, using the --static flag has some licence restriction, but here it can be used without limitation.

In your bundle you need to put some glue shared libraries that are used by the Mono runtime like this:

  • libgdksharpglue-2.so
  • libgladesharpglue-2.so
  • libglibsharpglue-2.so
  • libgtksharpglue-2.so
  • libMonoPosixHelper.so
  • libpangosharpglue-2.so
  • uiX11Util.so

All these files (except uiX11Util.so) are taken from mono environment. The last one (uiX11Util.so) is OLPC specific and allows to setup some X11 atoms needed by the Sugar interface. These files are placed in the bin directory of the activity.

How to run a Mono activity

You can find a sample activity written using Mono.

Interface with the native subsystem

Create new application

Sugarize existing application

More documentation will be released as soon as possible.