4. Testing installation and compiling examples


This chapter describes how to compile and run the .NET examples distributed with MOSEK.

To use the MOSEK .NET interface, a working MOSEK installation must be present — see the MOSEK Installation manual for instructions. In the following we assume that assume that MOSEK is installed in the default directory

C:\Program Files\mosek

The MOSEK .NET interface is defined in

C:\Program Files\mosek\6\tools\platform\win32x86\bin\mosekdotnet.dll

The distributed .NET examples are found in

C:\Program Files\mosek\6\tools\examples\dotnet

Please note that the Windows “Program Files” may be different for non-US installations.

4.1. Compiling and running from the command line

To compile an example, say lo1, with the Microsoft .NET compiler, open a DOS box with paths for Visual Studio set up (usually in the Start menu, the sub-menu for Visual Studio contains an entry that starts a DOS box with everything set up). Change directory to where the examples are found:

  c:
  cd "\Program Files\mosek\6\tools\examples\dotnet"

Then the following line compiles lo1.cs into an executable lo1.exe:

  csc /r:"c:Program Files\mosek\mosek\6\tools\platform\win32x86\bin\mosekdotnet.dll" lo1.cs

As for the Visual Basic example, the equivalent command looks as follows

  vbc /r:"c:\Program Files\mosek\mosek\6\tools\platform\win32x86\bin\mosekdotnet.dll" lo1.vb

To run the example, the system must be able to locate mosekdotnet.dll. To ensure this, either copy mosekdotnet.dll into the directory where lo1.exe was created, or ensure that mosekdotnet.dll resides in the Global Assembly Cache.

The program can now be executed by entering on the command line:

  lo1

4.2. Compiling the example using nmake

A makefile for use with nmake is available in

C:\Program Files\mosek\6\tools\examples\dotnet\Makefile.win32x86

or

C:\Program Files\mosek\6\tools\examples\dotnet\Makefile.win64x86

depending on the platform.

To compile all examples using this makefile use the command

  nmake /f Makefile.win64x86 all

4.3. Visual Studio project

The example lo1.cs also exists as a Visual Studio 2008 project.

c:\Program Files\mosek\6\tools\examples\dotnet\vs2008\MosekLo1

To use this project first copy the directory to somewhere with write permissions. E.g

C:\Documents and Settings\USERNAME

Then open the Visual studio project file MosekLo1.csproj.

4.4. Using the interface DLL

The library mosekdotnet.dll may be used from any .NET compatible language such as Visual Basic, Microsoft C# or Microsoft Managed C++. Both the examples and the library should also work with Mono on most 32-bit platforms.

The library accesses methods in the native MOSEK library (mosek.dll), which from a .NET view is considered unsafe. This means that use of the library in certain restricted contexts is not possible — bulding and running an ordinary application and running it on a local drive is possible.

4.5. Interactive use of MOSEK

It is possible to use the MOSEK .NET API interavtively from .NET languages which implements a command-line interpreter, for example IronPython

http://www.codeplex.com/IronPython

or the third-party language Boo

http://boo.codehaus.org/

These can efficiently be used to create and examine the problems and solutions from MOSEK.

4.6. Linux and Mono

It is possible to use the .NET API from Mono v.1.2 and later. Mono is a free implementation if the .NET platform available here

http://mono-project.com/.

The .NET dll is not included in the Linux distributions of MOSEK, but the dll included in the Windows distribution can be used from Mono.

To do this you must have a complete MOSEK installed as described in “the MOSEK Installation Manual”. Set the environment variable

MONO_PATH

to point to mosekdotnet.dll for the 64-bit Mono).

You should now be able to compile and run the distributed .NET examples using Mono.

Wed Feb 29 16:04:36 2012