This page is likely outdated (last edited on 30 Jul 2009). Visit the new documentation for updated content.

Compiling GtkSharp

Table of contents


This article describes how to build Gtk# >= 2.12.9 on Windows.

We recommend to use Gtk# trunk from our AnonSVN repository which currently targets Gtk+ 2.14 as it builds much faster.


Building GTK# 2 uses a similar process as Compiling_Mono_on_Windows. First, we’ll need some more dependencies:

  • Microsoft’s .NET Framework and SDK. If you’re building Gtk# 2.12, you need version 1.1 whilst trunk builds against .net 2 or any later version. Do not try to build Gtk# 2.12 against .net 2.

The MS .NET SDK is needed because the gtk-sharp2 build currently uses the disassembler(ildasm) and gacutil from the MS SDK for a portion of the build.

Now the Gtk dependencies:

If you want to build Glade#(optional):

Extract these zip files to the same location by using Microsoft’s xcopy or the very useful copy function in 7-zip which can also handle directory structures.

Add the ZIP_FILES\bin directory to your path(Windows XP: control panel->System->Advanced->Environment variables->Path) and run gtk-demo.exe in the same directory to test your Gtk+ installation.

As we have to use the win32 pkg-config from the Gtk+ bundle(because has supports for dynamic disks such as C:/devel/target/… needed by the Gtk+ pkg-config files), create a symlink from your ZIP_FILES/share/aclocal/pkg.m4 file to /usr/share/aclocal/pkg.m4:

ln -s /cygdrive/c/ZIP_FILES/share/aclocal/pkg.m4 /usr/share/aclocal/pkg.m4

If the target already exists, uninstall the cygwin pkg-config package.

Now you should create some symlinks to shorten the cygwin paths and to avoid spaces. For example:

ln -s "/cygrive/c/Windows/Microsoft.NET/Framework/v2.0" /dotnet
ln -s "/cygdrive/c/Program Files/Microsoft.NET/SDK/v2.0/Bin" /sdk
ln -s "/cygrive/c/ZIP_FILES/bin" /gtk

Build process

Make sure that Mono is not in the path, and put the MS tools in the path. Here’s an example of how to do this from the cygwin bash shell:

export PATH="/dotnet:/sdk:/gtk/bin:/bin"

Now we can start building. Unpack the gtk-sharp2 source and enter it’s directory. Here are the commands to build:

export CC="gcc -mno-cygwin"             # Make sure we're not dependent on cygwin
./configure --prefix=/tmp/install       # Choose any prefix you like, call bootstrap-2.xx instead when building SVN
make install

Add the INSTALL_PREFIX\lib directory to your Windows(not Cygwin!) Path as well. The .NET dll’s will be placed in the MS GAC. Enjoy!


  • The most likely reason for the build to fail is that you are using Cygwin’t pkg-config package instead of the one that is shipped with the Gtk+ bundle. Make sure that you uninstalled Cygwin’s pkg-config and put “/gtk/bin” in your PATH.

  • Building Gtk# 2.12 with .net >= 2.0 is known not to work.

  • If you still can’t get it to work, write a mail to the Gtk# mailing list (see Mailing_Lists).