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:
1 comment:
Thank you so much. I was banging my head against the wall trying to compile anything with gtk on Ubuntu. `pkg-config --cflags gtk+-2.0 --libs gtk+-2.0` is the piece I was missing.
Post a Comment