1
votes

I am trying to set up GTK# to work with mono on windows. the install was successful, and I can get windows forms programs to compile with mono. I have GTK# in my PATH. this is what i get when trying to compile it. i don't see the output it's referencing. i really don't know what to do from this point. i have repaired the install, i have reinstalled it, i have rebooted the computer, but it still didn't work.

thx in advance

1

1 Answers

0
votes

If you read the Mono's documentation for Gtk#, it says:

To some of you that have used the csc compiler on windows may notice the “-pkg:” as a little odd. This doesn’t exist in csc because Mono comes from the world of Linux. What that does is lookup for a package config file under that name. In the package config folder exists a file name “gtk-sharp-2.0.pc” which contains (amongst other information) on the location of the libraries for that package. That way we don’t have to type out “-r:gtk-sharp-2.0.dll -r:atk-sharp-2.0.dll -r:pango-sharp-2.0.dll ….” all by hand.

One would assume that, provided the docs, everything needed to compile is present, including pkg-config, the executable that actually reads the gtk-sharp-x.y.pc file and configures the compilation. However, either it does not exist, or the PATH has not been correctly configured.

First of all get sure that you have installed Mono and Gtk#. I know it seems it is redundant, but both installers are needed.

Then, decompose the compilation command so pkg-info is not needed.

$ mcs -r:/usr/lib/mono/gtk-sharp-2.0/gtk-sharp.dll -r:/usr/lib/mono/gtk-sharp-2.0/atk-sharp.dll -r:/usr/lib/mono/gtk-sharp-2.0/glib-sharp.dll gtksharpdemo.cs

I'm in a Linux machine, so the complete paths to the assemblies won't be those ones. I guess it will be something like:

$ mcs -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll" -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\glib-sharp.dll" -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\atk-sharp.dll" gtksharpdemo.cs

Finally, this is all much easier if you work with MonoDevelop. You can start your project from the Gtk# 2.0 template, and everything will be set up for you. If you prefer to start from the empty template for some obscure reason, then go to the "references" section of the project, and add "System", "gtk-sharp", "glib-sharp", and "atk-sharp".

This is also all possible from Visual Studio, but I don't have any experience using it.