Thursday, January 15, 2009

Hello World With GTK+ Programming

Fixing the "Package gtk+-2.0 was not found in the pkg-config search path" error
getting the Hello World GTK+ example to compile.

Today, I thought I'd try my hand at GTK+ programming. Win32 GUI programming was fun, and I didn't go all the way till the edge of the world with it, but I wanted to try something different for more insight.

I started off by looking at the Hello World GTK+ tutorial here, and tried compiling the following code.

#include <gtk/gtk.h>

int main (int argc, char *argv[] )
GtkWidget *window;

gtk_init (&argc, &argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);

gtk_main ();

return 0;

Compilation failed with the error "Package gtk+-2.0 was not found in the pkg-config search path" so I figured I didn't have the GTK+ development library. A quick search from the Synaptic Package Manager revealed that there was a libgtk2.0-dev package that I didn't have installed.

As soon as I installed the package, compiled the source code and executed the program, a GTK+ window popped up! This could be a whole new beginning for me. Let's so how far it goes.

No comments: