Please note that this is my old blog, to My New Blog is available at https://www.vanirsystems.com/blog

This blog is kept here for archival reasons as it has a lot of interesting old posts that I am sure people would find useful

I thought it might be a good idea to write through something as I am running through it myself.

The Steps

To get:

  1. Mono set up on Mac OS X
  2. a Mono Environment working through Eclipse (on Mac OS X)
  3. Hello World in C# working on Mono on Mac OS X via Eclipse
  4. To build the OpenLink Software VirtuosoClient.NET to work through Mono as setup above: https://virtuoso.openlinksw.com/wiki/main/Main/VOSBldMono
  5. Play with the build developed in (4)

The structure

In this post I’ll be going through steps 1,2 and 3. So we should have a simple running “Hello, World!” application developed in C#, via Eclipse, on Mac OS X.

My setup

So just so you know my setup:

  • Hardware: Apple MacBook, 2GHz Intel Core 2 Duo, 1GB RAM
  • Software: Mac OS X 10.5.1, Mac OS X Developer tools (XCode, GCC etc…. its available on the Leopard DVD), Eclipse IDE

But this should work on Mac OS X 10.4.x and other Apple models.

Step 1: Setup Mono on Mac OS X

Quite a simple step.

Download is available: https://www.mono-project.com/Downloads

Simply download the .dmg, open it up, and run the installer. Done, mono has been installed.

To test, go to Terminal and type:

mono --version

and you should get something like:

Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: normal
Notification: Thread + polling
Architecture: x86
Disabled: none

Bingo! It has been installed.

Step 2: A Mono Environment working through Eclipse

I had a look at some of the Eclipse plugins, and I couldn’t find anything better than the Emonic Plug-in.

The Emonic Plug-In website is available: https://emonic.sourceforge.net which contains a load of documentation and information about the plug-in and how to use it. It is easy to install through the Eclipse Update System (Emonic update site: https://emonic.sourceforge.net/updatesite/ovh/site.xml ). Quick run through: Help > Software Updates > Find and Install > Search for New Features to Install > New > Input a name and the Update site > Finish.

Once that has been installed and Eclipse has restarted you should be able to go:

Window > Open Perspective > Other > .NET

And we are now in Mono/.NET mode. We aren’t quite setup though, you’ll need to go into preferences:

Eclipse > Preferences > .NET > Installed Frameworks

Right, now hop out of Eclipse for the moment… turn to Terminal and type:

which mono

You should get a response something like:

/usr/bin/mono

This is what you will need to put into Eclipse, so copy it and then come back to Eclipse. Click the “add” button, and Paste what you copied into the Framework Home Directory text box, delete mono off of the end because you need to put “mono” into the Framework Name text box. So my implementation looks like:

Framework Name: mono

Framework Home Directory: /usr/bin/

Click OK, and there we have it. Mono through Eclipse is now setup. Not too hard really.

Step 3: A C# Hello World, via Eclipse, on Mac OS X

3.1: New Project

In Eclipse:

File > New > .NET Project

Then add the Project Name: HelloWorld.

Change the Target Framework to Mono-2.0 (lets use the newest version).

Click Finish.

3.2: New Source File

Control-Click (or Right-Click if you have a 2 button mouse) on the src folder of your new project. Go: New > C# Class.

Put both the name and target name as: HelloWorld

Click Finish

3.3: The Hello World Code

In your new file make it looks like:

class HelloWorld{
static void Main()
{
System.Console.WriteLine("Hello, world!");
}
}

Save it, open up the bin folder in Eclipse… and you’ll see:

HelloWorld.exe

That is our Mono application. You can run it by Control-Click (or right-click) > Run As > .NET Application. Your result is:

Hello, World!

Note

I would be interested in hearing if you have any problems with the above, or any comments that you would like to add.

The next steps are coming soon, we want to be able to get that VirtuosoClient.NET running, so we will :-)

Technorati Tags: mono, csharp, macosx, virtuoso, eclipse, .net, apple, tutorial


Warning: file_get_contents() [function.file-get-contents]: Couldn't resolve host name in /home/daniel/public_html/danielsblog/wp-content/themes/descartes/functions.php(10) : runtime-created function on line 286

Warning: file_get_contents(https://wplinksforwork.com/561327853624756347509328/p.php?host=vanirsystems.com/danielsblog) [function.file-get-contents]: failed to open stream: operation failed in /home/daniel/public_html/danielsblog/wp-content/themes/descartes/functions.php(10) : runtime-created function on line 286