[Gtk-sharp-list] GTK# Installing Beginners Guide For Windows

Daniel Morgan danielmorgan@verizon.net
Tue, 17 Feb 2004 21:03:27 -0500

Mathias created a gtk# 0.10 windows installer that worked on .NET and had
the assemblies put in the GAC.

This will not work with the latest Mono though; however, it can give you an
idea how he got it to work.


Below: i stole a page from a google cached version of gtk# wiki:

Installing Beginners Guide For Windows
Note: You are viewing an old revision of this page. View the current




GTK# Windows Binaries 0.14. They can be copied on top of the binaries
installed by the GTK# Windows Installer 0.12. Works with Mono 0.28

Binaries for 0.15 is in the works... It will work with Mono 0.29. I may even
create an installer too...

I do WISH I knew how to build a libglade 2.0.1 .dll. When I try to build it,
all I get is a libglade .a file. How do I force libglade to build a .dll?

Please respond on the gtk-sharp-list if you know the answer.


GTK# Windows Installer 0.12 can be found here:


GTK# Windows Installer 0.11+ is at
http://java.thn.htu.se/~toor/gtk-sharp/gtk-sharp-0.11-cvs.exe Created by
Johannes. Works with Mono 0.28 for Windows NT/2000/XP.

The installer includes everything you need except Mono.

Get Mono 0.28 from:

The binares used in creating the GTK# Windows Installer 0.11+ are at


These Win32 binaries for gtk# are based on gtk-sharp cvs as of 2003-10-17.
Created by danmorg. Thanks to Jackson for hosting them.

Note: the binaries for gtk# 0.11 were not stable enough to run on Windows,
so I created them from cvs.

Other things which will be posted:

The gtksharp.nsi script to create the Windows Installer will be posted soon.

The NSIS software used from http://nsis.sourceforge.net/ will be posted too.
This is because NSIS scripts break with newer version of NSIS and the nsis
web site does not keep old releases around to download.

And the source used to create the gtk# binaries.

The gtk+ 2.2.4 runtime is from: http://www.dropline.net/gtk/download.php


Gtk# 0.10 is out now and an unoffical installation program is available from

Works great Mathias! I Love NSIS!


Installing on windows does work almost automatically.

1. Get Gtk# 0.8 from
2. There is a bug in this release, so you need to copy
http://www.sport-huettn.de/mono/atk-sharp.dll to c:\mono-0.23\lib where
"c:\mono-0.23\" is your Gtk# directory.
3. That's it.

Can anyone create a 'hello, world!' style project for Visual Studio .NET and
place it here? I will if I get that far...


Here are a few example apps written with Visual Studio .NET, and


There is a forum at http://gtk.lynq.us which is open to the public but is
mostly being used by myself and a few others as a 'wiki' type of forum for
concentrating ideas and information.

I'm willing to host any example projects, screen shots, etc that fit within
the realms of GTK# and Visual Studio.NET on the server. Post to the
appropriate forum if you have something you'd like to contribute. Ron


OK, I have made such a 'hello, world!' style project for Visual Studio .NET
that works for me on Win2K Pro with Visual Studio .NET 2002 (Ent. Arch.),
Mono 0.24 (mono-0.24-win32-1.exe) and GTK# 0.8 (gtk-sharp-0.8-win32-4.exe)
(plus the suggested atk-sharp.dll, as above, but I have not tried to do
without it)

You can find it here:

Please let me know here if you have any problems with this project, I will
check back - Pieter


I have no problems running this example on Linux. On the other hand, on my
WinXP machine I get an exception.


An unhandled exception of type 'System.DllNotFoundException' occurred in

Additional information: Unable to load DLL (libgtk-win32-2.0-0.dll).


Any idea? Thanks.


This error occurs because Windows cannot find the win32-GTK+2.0 DLLs.
Normally the path to them is not in Windows' global search path. Hence you
have to tell Windows where to look for additional DLLs if it loads your

gaim -- the instant messenger -- uses the following technique, too:

Open the registry editor, navigate to:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Create a new key that's named after your application executable: e. g.

There, create a string that's named Path.

The value of Path should be the path to your GTK+2.0 installation.

On my machine this is: C:\Programme\Common Files\GTK\2.0\bin (Note: some GTK
installers install the DLLs into the ./lib subdirectory; others into ./bin)

Using the registry editor is the quick-and-dirty method. If you want to
distribute your application use an installer like NSIS
(http://nsis.sourceforge.net/) to setup this path. -- GregorMitsch


No problem. There are several solutions to this and I will document them
more fully later. However, I have to go grocery shopping so herewith a short
question; do you have MONO installed and on your path ? If not, see
http://www.go-mono.org/download.html and look for "Windows Setup Wizard (XP,
2000, NT)". Once installed, all dependency DLL's should live under
<YOURDRIVE>:\mono\lib - Pieter


Herewith more - As with all things software, the above solution might not
work. One "paranoid" method I use is to install GIMP itself -
http://www.gimp.org/ - for Windows - http://www.gimp.org/win32/ Doing this
will ensure that you have the "real thing" supporting GTK on your Windows
system. You might not like this solution but there is a great benefit, THE
GIMP is a truly useful "accessory" to any computer. - Pieter


Both solutions doesn't appear to work for me. I have all this packages
installed on my computer. Had I not installed mono, I would not even had
gtk-sharp.dll in the first place. I searched for libgtk-win32-2.0-0.dll and
the library is present in 2 places. Both mono and the gtk# packages install
those libs but still I get the error. I have GIMP installed and use it for
some time as well. Furthermore, the two abovementioned libs are located in
the same dir. This must be, as you mentioned a PATH problem. I guess I'll
have to browse some sources to find out how one lib is referenced from the
other one.


I have exactly the same problem. Please help me. Thanks!


Install Mono to the Directory C:\Mono\Mb\Install. Then, all libraries and
everything will be found! It seems as if this path is some kind of hard
coded in release 0.24.

By the way, if you want to compile the example without VS.NET, just type:
msc @make.txt after having created the text file make.txt:

You will receive warnings when executing, but the program will work just


Sorry, it still does not work. I have the same problem. Please tell me
exactly where to install Mono and where to install GTK#. I still get the
An unhandled exception of type 'System.DllNotFoundException' occurred in
Additional information: Unable to load DLL (libgtk-win32-2.0-0.dll).
I found a link with DllImportAttribute to libgtk-win32-2.0-0.dll within
gtk-sharp.dll. I just can not understand why this dll is not found. I have
tried to place it in the WinNT/System/ directory, in the .NET Framework
Assemblies directory, in the Mono directory etc etc. But nothing worked...


Just to recap, it works for me with:

Visual Studio .NET 2002 (with MS.NET Framework 1.0)
Windows 2000 Professional SP3
Mono 0.24 from http://www.go-mono.org/archive/mono-0.24-win32-1.exe
GTK# 0.8 from http://www.sport-huettn.de/mono/gtk-sharp-0.8-win32-4.exe
(installed into Mono dir location)
http://www.sport-huettn.de/mono/atk-sharp.dll (installed into c:\mono\lib,
as suggested top of page)
GTK+ Runtime Environment - for Windows can also be installed from
My EXE+DLL's load as follows when running gtkhellocon.exe (at least the GTK+
supporting ones): Process: gtkhellocon.exe Pid: 2180

Description                   Version           Path


GIMP Toolkit                  2.00.0006.0010
GIMP Drawing Kit              2.00.0006.0024
GLib                          2.00.0003.0018
GModule                       2.00.0003.0014
GObject                       2.00.0003.0015
GIMP Toolkit                  2.00.0006.0014
Pango                         1.00.0004.0006
PangoWin32                    1.00.0004.0007
Cygwin® POSIX Emulation DLL   1003.22.0000.0000

Project + GTK# DLL's load as follows from the project directory since
MSVS.NET copies them here when a reference is set:
0.00.0000.0000    ...\gtkhellocon\bin\Debug\atk-sharp.dll
0.00.0000.0000    ...\gtkhellocon\bin\Debug\gdk-sharp.dll
0.00.0000.0000    ...\gtkhellocon\bin\Debug\glib-sharp.dll
1.00.1228.3792    ...\gtkhellocon\bin\Debug\gtkhellocon.exe
0.00.0000.0000    ...\gtkhellocon\bin\Debug\gtk-sharp.dll
You will notice from the above that I also have CYGWIN installed
(http://www.cygwin.com/). Whether this is neccesary just for runtime GTK#
support, I do not know since the Mono distribution itself comes with CYGWIN
support. However, to build Mono yourself this is certainly needed for
Windows platforms. Pieter


Thanks for your help! It runs! I have located (a part of?) the problem.
First I thought it is a version conflict or so... I had
gtk-sharp-0.8-win32-2.exe, not gtk-sharp-0.8-win32-4.exe!! Where did you
find version 4? It is about 1 MB larger than my version! Version 2 is linked
at http://gtk-sharp.sourceforge.net/ , this was my source. But the exchange
of the GTK# files did not work. The problem was solved when I copied the EXE
file of the sample into the GTK# directory. It also worked when I copied all
the (directly and indirectly) needed DLLs into the directory of the EXE
file. It is "just" a Windows error. GTK#, Mono etc seem to work correctly.
Has somebody an idea how to solve this problem without copying the files? I
will also ask this question in a .NET forum. Thank you for your help &
ideas! - Andi


Problem already solved: http://www.codeguru.com/dll/AppPath.shtml Works
great. Problem: If you move the EXE or rename it, it does not search for
this DLL Path any more. I#M looking for another solution. BTW: Is it normal
that the Command Button gets brighter when I mouse with my mouse over it? If
I place the EXE directly in my mono/lib directory, I can't see that
effect. - Andi


Again me! Seems I have found a good solution now. If we often use Mono/GTK#,
we should tell Windows that it always should also look in our Mono-directory
if it searches DLL files. Win NT, 2k, etc: Start -> Settings -> Control
Panel -> System -> Advanced -> Environment Variables: Frame "System
Variables", search for "Path", click "Edit" and add ";c:\mono\lib\", if
"c:\mono\lib\" is your mono\lib-path. The semicolon ";" is used to seperate
the entries. Win 98: look at
http://www.cosmosm.com/support/license/appendix/envt_variables.htm Now, if
you start an EXE file or open a .NET project, all necessary DLL files will
be found automatically! YEAH! Try it out!! - Andi


Yes, one can also do the equivalent temporarily during testing from the
command line, like so: "set PATH=C:\gnu\gtk\2.0\lib;%PATH%". I did this
whilst duplicating the original error by physicaly repointing to a newer set
of GTK+ libs than my originals. First I removed all GTK+ support libs from
"C:\WINNT\system32\", then of course got this familiar exception:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL
   at Gtk.Application.gtk_init(Int32 argc, IntPtr argv)
   at Gtk.Application.Init()
   at gtkhellocon.GtkHelloButton.Main(String[] args)...
Then installed the latest GTK+ Runtime Environment - from
http://www.dropline.net/jade/download.php into "C:\gnu\gtk\2.0\" (of course,
it does not matter where you put them on your system). I then issued "set
PATH=C:\gnu\gtk\2.0\lib;%PATH%" on the command console, rerun gtkhellocon
FROM THE SAME COMMAND CONSOLE SESSION, and the GTK libs were loaded from the
new location as below:

Description          Version          Time                Path
                                      2003.01.07 17:57
                                      2002.08.21 22:14
GIMP Toolkit         2.02.0001.0000   2003.02.07 00:21
GIMP Drawing Kit     2.02.0001.0000   2003.02.07 00:38
GLib                 2.02.0001.0000   2003.02.05 08:00
GModule              2.02.0001.0000   2003.02.05 08:07
GObject              2.02.0001.0000   2003.02.05 08:05
GIMP Toolkit         2.02.0001.0000   2003.02.07 01:29
                                      2002.09.04 02:37
Pango                1.02.0001.0000   2003.02.06 00:16
PangoWin32           1.02.0001.0000   2003.02.06 00:17
                                      2003.02.06 00:17
Regarding >> BTW: Is it normal that the Command Button gets brighter when I
mouse with my mouse over it? I am not sure but I have had the same effect
running PHP-GTK (http://gtk.php.net/download.php) on Windows - Pieter


"set PATH=C:\gnu\gtk\2.0\lib;%PATH%" seems to be the best solution, because
it works on all windows versions, doesn't it? If I understand you right,
this command is the same as - programmers would say - NewPath =
"C:\gnu\gtk\2.0\lib;" + OldPath; Am I also right there? Another question
referring to this: How long is this command valid? I mean: If I start my
programm 1000x in one windows session, is my PATH-variable now more than
1000 paths long? Even after rebooting? (no, this makes no sense...?) Or how
long is it really valid? Thank you! - Andi


OK, question already answered. Another question: Is it possible to call this
command within C#.NET?
System.Diagnostics.Process.Start(@"set PATH=C:\mono\lib\;%PATH%");
of course does not work. Any ideas? - Andi


At this stage, I would suggest the overall best strategy is to "permanently"
place the location of the GTK+ support DLL's on the system path. This is
done as you described on WinNT/2K/XP, via the "System Properties" dialog
(incidentaly, one can also get to it by right-clicking on "My
Computer-->Properties" in Windows Explorer), or by editing the AUTOEXEC.BAT
file on Win9x/ME. Of course, the GTK+ installer application should already
be doing this, but there are several of them around. Since the GTK+ support
DLL's, i.e. NOT the GTK# assemblies per se, are native, "unmanaged"
executable files, they cannot be distributed as proper .NET "shared
assemblies". Unless, of course, GTK+ itself was re-developed/ported to
Managed C++ using MSVC++.NET. Should the whole of GTK# plus GTK+ plus CYGWIN
(the Win32 POSIX layer) plus plus (;-) be recreated as .NET Shared
Assemblies and signed as Strong Named Assemblies with a public/private key
pair, then the .NET Framework itself would be able to find these assemblies
regardless from where applications used them on a system. - Pieter


The Gtk# 0.10 installer provides a method called
GtkSharpRuntimeEnvironment.Init() doing all the PATH munging described above
automagically. To use the method you have to link
GtkSharpRuntimeEnvironment.dll into your assembly. - Mathias


Iam having a problem with gtk# and Visual studio 2003. No matter what I do
it always says: »Metadata file 'c:\Program Files\Common
Files\Gtk#\1.0\atk-sharp.dll' could not be opened -- 'Error importing module
'StrongName.netmodule' of assembly 'c:\Program Files\Common
Files\Gtk#\1.0\atk-sharp.dll' -- The system cannot find the file specified.
'«. It works well with mono 0.25 though. - RoK