Table of contents
The document describes how to generate OpenMI dlls and executables on a Linux machine. This is done by using Mono, a .NET Open Source software for different platforms. Most of the OpenMI functionality has been ported:
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. prefix=/usr/lib/mono/2.0 Name: WindowsForms |
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 |
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 automatically a resource file to a C# file. On a Linux machine naming conventions guarantee the correct assignment. The C# source and its resource file must have the same prefix. This first part of the prefix must be the namespace.
Example for ElementSetViewer |
The original Windows resources contained *.bmp graphics with a 24bit colour depth. Mono on 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 that the developers of OpenMI GUIs use Forms elements instead of WPF elements.
Mono Forums are very helpful: http://www.go-mono.com/forums/
Error messages are often the same as in Microsoft Windows .NET. You can look them up on the MSDN homepage.
Fig. 1: Directory structure
After the first 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:
Use Subversion (svn) for download of the C# sources:
The dlls and exe files will be copied to $OPENMI_DIR/Oatc/src/csharp/bin/.
The IDE MonoDevelop is an alternative to the scripts. It imports Microsoft projects by loading the *.sln file. The author had some compilation problems with MonoDevelop 2.0 Alpha without clear error messages. Experienced developers may find a solution. Furthermore, MonoDevelop will be constantly improved in 2009, s. http://www.mono-project.com/Roadmap
It is recommended to extend two environment variables:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OPENMI_DIR/Oatc/src/csharp/bin/ |
Mono applications do not run directly on the Linux system, they are interpreted in a runtime engine, comparable to the virtual machine in java. Thus, the command in the terminal window command line has to start with mono:
You have done it.
The generated applications will probably run on further platforms. On non-SUSE Linux derivates it may work without re-compilation. But it has not been proved yet. Interested persons are invited to test. A short notice to the community, e.g. to the OpenMI Forum on SourceForge, would be appreciated.
Yes, you can generate a set of dlls and exe files for Linux and a set for Windows with the same sources. The method Gui/Core/Utils.IsRunningOnMono decides during runtime, whether it runs on Mono or not. The build.*.sh scripts are tailored for Linux, for Windows you can use the Visual Studio projects.