You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Table of contents

1. Introduction

The document describes how to generate a LinkableComponent on Linux:

  • how to compile a shared library for a Fortran <engine>
  • how to port a C# wrapper for this shared library from Windows to Linux. The wrapper contains a class for accessing the Fortran Dll <engine>DllAccess and two outer classes <engine>DotNetAccess and <engine>Wrapper.

2. Technical prerequisites
2.1. Machine and OS of the test system

  • workstation with an Intel Xeon processor
  • 64bit openSUSE 11.0

2.2. Mono

  • Mono v. 1.9.1. for openSUSE 11.0 in 64 bit mode. V. 1.9.1. is also referred to as Mono 2.0.
  • The standard and the sdk sources should be compilable with previous versions. But the GUIs require Windows.Forms, which has been shipped with v. 1.9.1. in Oct. 2009.

3. How to compile and execute a Mono application
3.1. Commands

Command for generating a dll:

gmcs -target:library -out:<target>.dll -r<linkedLib_1>.dll,<linkedLib_k>.dll -pkg:<package_1>.pc;...;<package_m>.pc <source_1>.cs <source_n>.cs

-r:<linkedLib_?>.dll : reference to linked shared libraries (path and name)

-pkg:<package_?>.pc : ASCII files (path and name), that refer to linked shared libraries <linkedlib_?>.dll. They contain the path and the version of the dll. Example for the Windows.Forms:

prefix=/usr/lib/mono/2.0
exec_prefix=$

Unknown macro: {prefix}

libdir=$

Unknown macro: {exec_prefix}

Name: WindowsForms
Description: Windows Forms
Version: 2.0
Libs: -r:$

Unknown macro: {libdir}

/System.Windows.Forms.dll

Command for generating an exe file:

gmcs -out:<target>.exe -r<linkedLib_1>.dll,<linkedLib_k>.dll -pkg:<package_1>.pc;...;<package_m>.pc <source_1>.cs <source_n>.cs
3.2. Mono and Grapical User Interfaces GUIs

The GUI sources use Windows.Forms, that works with resource files in order to design the graphical elements. The Windows resource files (*.resx) are generated automatically in the Microsoft Visual Studio IDE. Linux applications do not process them and create a "resource not found" exception during runtime. Thus, the resources have to be converted with the Mono tool resgen / resgen2. The following command generates a Linux readable resource <name>.resource:
resgen <name>.resx generates a Linux readable resource <name>.resource .
Visual Studio assigns a resource file to a C# file automatically. On a Linux machine naming conventions guarantee the correct assignment. On linux systems C# and resource file must have the same prefix. This first part of the prefix must be the namespace.

Example for ElementSetViewer
namespace: Oatc.OpenMI.Gui.Controls:
Linux source name: Oatc.OpenMI.Gui.Controls.ElementSetViewer.cs
Linux resource name: Oatc.OpenMI.Gui.Controls.ElementSetViewer.resources

The original Windows resources contained *.bmp graphics with a 24bit colour depth. Linux could not process them. The solution was to convert the BMPs externally to 8bit GIFs, before adding them to the resource in the Visual Studio IDE.

Mono can not process all type of GUIs. Mono 2.0 has nearly the full functionality of Windows.Forms. It does not support the WindowsPresentationFoundation WPF, shipped since .NET 3.0, which generates resources in XAML style or logical resources. Thus, it is highly recommended to use Forms elements in OpenMI GUIs instead of WPF elements.
3.3. Help for Developers

Mono Forums are very helpful: http://www.go-mono.com/forums/
A part of the error messages are the same as in Microsoft Windows .NET. You look them up on the MSDN homepage.
4. OpenMI on Mono in five steps
4.1. Download from SourceForge

Fig. 1: Directory structure

  • No labels