# Mac OS X, Mono, Eclipse and Virtuoso
I thought it might be a good idea to write through something as I am running through it myself.
The Steps
To get:
- Mono set up on Mac OS X
- a Mono Environment working through Eclipse (on Mac OS X)
- Hello World in C# working on Mono on Mac OS X via Eclipse
- To build the OpenLink Software VirtuosoClient.NET to work through Mono as setup above: https://virtuoso.openlinksw.com/wiki/main/Main/VOSBldMono
- 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
February 6th, 2008 at 3:16 am
Thanks for the informative post. I needed to set the Framework Home Directory to “/Library/Frameworks/Mono.framework/Home/bin” rather than “/usr/bin”
February 6th, 2008 at 6:52 am
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.
February 6th, 2008 at 8:49 pm
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?
December 31st, 2008 at 5:12 pm
[...] 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. [...]
January 2nd, 2009 at 2:54 am
[...] OS X???Mono, Eclipse ? Virtuoso.?? Eclipse [...]
April 21st, 2009 at 2:08 am
[...] 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. [...]
April 22nd, 2009 at 9:02 pm
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/
October 9th, 2009 at 5:11 pm
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