GTK# Hello World with Mono
03Mar08
Here’s a simple tutorial that will show you how to run a Mono GTK-Sharp application under both Mono and the .NET framework. The general documentation leaves some parts out, so here’s a concise guide to getting that first application ready. This tutorial was written using Mono 1.2.6 with Gtk# 1.0/2.10 and .NET framework 1.0/1.1/2.0.
- Get Mono, install with Gtk#
- Get gtkgac1.0_2.10.zip, unpack in the latest .NET directory with gacutil.exe (on my system, it’s C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322) so that there is a gtkgac folder in the directory
- Run gtk_gac1.0.bat and gtk_gac2.0.bat
- Run gacutil in the .NET directory (to avoid running the Mono gacutil) like so: gacutil /l gtk-sharp. Two assemblies should appear, 1.0 and 2.10
- Download hellogtk.cs into your development directory.
- Compile with the following command: mcs -pkg:gtk-sharp-2.0 hellogtk.cs
- To remove the console window, add the -target:winexe flag
- Run with (.NET) hellogtk and with (Mono) mono hellogtk.exe
- You’re done!
Filed under: Uncategorized | 4 Comments
Tags: csharp, gac, gacutil, gtk, mono
I followed the instructions but I keep getting this error:
error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/pango-sharp.dll’ could not be found
error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/atk-sharp.dll’ could not be found
error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/gdk-sharp.dll’ could not be found
error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/gtk-sharp.dll’ could not be found
error CS2001: Source file `Files/Mono-2.0.1/lib/mono/gtk-sharp-2.0/glib-sharp.dll’ could not be found
Compilation failed: 5 error(s), 0 warnings
I guess the problem have to do with the path, but I don’t know how to fix it?
I managed to fix it previously I installed the mono application in Program Files but now I have installed it directly to the c:
Glad you got it working, but the error message means your assembly path data is somehow wrong. Try a clean install whenever possible.
Actually, this is a bug still in the Mono package. It appears to not like the space in the “Program Files” directory. Overriding the default install folder seems to be the only way to get it working properly out of the box.