02 August 2010

Installing and running GTK applications on Linux (Ubuntu 10.04)

Al salamo Alykom,
Hi folks, How are you...

Today I'll talk about installing GTK and building simple GUI app using it.

to install GTK+2.0, from the command line write:
sudo aptitude install gnome-core-devel build-essential

That's all.

Now, Let's write a simple program using gtk+:
#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;
}

to compile, use the following command:
cc hello_gtk.c `pkg-config --cflags gtk+-2.0 --libs gtk+-2.0`

And here's the run result:
Post a Comment