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

# Mac OS X, Mono, Eclipse and Virtuoso

mono, programming, technological @ 02 January 2008

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

8 Responses to “Mac OS X, Mono, Eclipse and Virtuoso”

  1. Jon Says:

    Thanks for the informative post. I needed to set the Framework Home Directory to “/Library/Frameworks/Mono.framework/Home/bin” rather than “/usr/bin”

  2. Chris Peterson Says:

    Thank you! I had been looking for a Mac IDE solution for .NET/Mono. Eclipse+Emonic is the least worst option so far. :-) Your installation instructions are very clear.

  3. Chris Peterson Says:

    Warning: Eclipse gets confused when you try to “Run .NET Application” if your .exe’s file path contains a space! Why is Eclipse bringing Windows headaches to my Mac? ;-)

  4. OS X + Eclipse + Mono Tutorial | Dot Mac Says:

    [...] Here is an interesting tutorial for developing .Net apps in OS X using the Eclipse IDE. The XCode equivalent is CSharpPlugin. If a native IDE isn’t important to you, running Visual Studio via VMware works just fine too. [...]

  5. ??Mono?Mac???.Net?? | ????? Says:

    [...] OS X???Mono, Eclipse ? Virtuoso.?? Eclipse [...]

  6. Rusty Razor Blade » Blog Archive » C# on the Mac with Eclipse Says:

    [...] It looks like developing using c# and eclipse on the Mac is pretty easy, at least on first glance. Here’s a good guide to get started. [...]

  7. Nils Says:

    Problem solved.
    I just created a symlink from the
    /Library/Frameworks/Mono.framework/Versions/2.4/share/NAnt/bin/
    directory to pkg-config located in
    /Library/Frameworks/Mono.framework/Versions/2.4/bin/

  8. John Tangney Says:

    Excellent! I had trouble when I left the default build mechanism as nant in the new project wizard. Choosing Ant made it work.

    Thanks for the great tutorial!
    -johnt

Leave a Reply