How to write and build a GTK+ app on Ubuntu


$ cat hello.c
#include

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

gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
label = gtk_label_new("hello, world");
gtk_container_add(GTK_CONTAINER(window), label);
gtk_widget_show(label);
gtk_widget_show(window);

gtk_main();
return 0;
}
$ gcc -Wall -g hello.c -o hello `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
$ ./hello

pkg-config simply outputs the headers and libraries that need to be passed to gcc.

More information here.

Telling Maven Integration plugin for Eclipse where Maven installation directory is under Ubuntu

The Maven plugin for Eclipse by default uses an embedded Maven installation which is Maven 3.0. It turns out this has some incompatibilities with Maven 2.x and you are likely better off using Maven 2.x, which is fortunately still the version in the Ubuntu repository.

To specify which Maven installation to use in Eclipse, go to Window -> Preferences -> Maven -> Installations. Click Add. The default Maven installation directory for Ubuntu is /etc/share/maven2. If you input the wrong directory you will get a "The selected directory is not a valid Maven directory" error message.