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

Compare with Current View Page History

« Previous Version 5 Next »

How to port the OpenMI environment from Windows to Linux

Table of contents

1. Introduction

The document describes how to generate and run Linux dlls and executables from the original Windows C# sources. This is done by using Mono, a .NET Open Source project on different platforms. Only few adjustments are necessary in order to port the complete OpenMI functionality:

  • the standard OpenMI.Standard
  • the source development kit Oatc.OpenMI.Sdk.*
  • the dlls and executables Oatc.OpenMI.Gui.* for running OpenMI in the configuration editor with GUIs or from command line.

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=${prefix}
libdir=${exec_prefix}
Name: WindowsForms
Description: Windows Forms
Version: 2.0
Libs: -r:${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

Further compile information for resources is given in section 3.3..
Applications compiled with Mono do not run directly on the linux system, they are interpreted on a runtime engine, comparable to the virtual machine in java. Thus, the command in the terminal window command line has to start with mono, e.g.:

mono Oatc.OpenMI.GUI.ConfigurationEditor.exe

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

After this step you should have a copy of the OpenMI sources on your machine with the directory structure displayed in Fig. 1. OpenMI-Version-1-Trunk is in this examples the name for the starting directory $OPENMI_DIR. There are two new subdirectories:

  • ./Oatc/src/csharp/bin: linux dlls / exe files
  • ./Oatc/src/csharp/Linux: shell scripts for building dlls / exe files and running UnitTests; *.pc files

Use Subversion (svn) for download of the C# sources:

create $OPENMI_DIR/Oatc/src/csharp and $OPENMI_DIR/OpenMI.Standard/src/csharp.

5.1 The Simple River Wrapper

The Simple River model uses the migration pattern shown in Figure 12. Figure 13 gives a detailed explanation of how the Simple River wrapper works in terms of the wrapper classes.

Fig. 13 Simple River wrapper classes

Filters for ElementSet and Dimension

  • No labels