How to install gtk development dependencies on Ubuntu?

Kraken picture Kraken · Mar 13, 2013 · Viewed 55.1k times · Source

I have the code from GTK tutorial in base.c.

I am working on Ubuntu and when I compile using

$ gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0` 

I get the following error

Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
base.c:1:20: fatal error: gtk/gtk.h: No such file or directory compilation terminated.

Being new to linux, can someone help me in setting up the environment so that I can compile/run the program successfully?

Answer

poolie picture poolie · Mar 13, 2013
$ sudo apt-get install libgtk2.0-dev

Generally speaking to build things based on libfoo, you need libfoo-dev.

In addition, to install anything that is needed to build a package, say gedit, you can run:

$ sudo apt-get build-dep gedit

Searching http://packages.ubuntu.com/ or Synaptic can help.