Take the 2-minute tour ×

hi every one i have a program in which i have include



i have used commands

sudo apt-get install libgtk2.0-dev glib sudo apt-get install glade

but still getting error that glib not found ans gtk/gtk.h not found. i am first time using this gtk . no idea how it works how to install it kindly help me thanks

i am doing c programming

share|improve this question
Are you using this in your command to compile: `gtk-config --cflags gtk-config --libs` –  yasouser Mar 11 '11 at 19:39
yes sir i am using these commands. –  tariq Mar 11 '11 at 19:43
sir i have only install packges as mention in the commands. am i missin some thing is any thing else i have to do?? –  tariq Mar 11 '11 at 19:44
Apparently the gtk-config command has been usurped by pkg-config --libs gtk+-3.0. –  Dave Jarvis Mar 24 '13 at 21:12
add comment

3 Answers

The command you're supposed to use (in more recent releases of linux/gtk) is pkg-config, not gtk-config. gtk-config is intended for pre 2.0 gtk development.

Consider the file you're compiling is called foo.c, to compile it under gtk-2.0, you would use, from the command line the command:

gcc `pkg-config --cflags glib-2.0 gtk+-2.0` foo.c -o foo `pkg-config --libs glib-2.0 gtk+-2.0`

This should compile, and give you a file foo, that can be executed.

but really, use a makefile, as this stuff is a pain to keep typing. I would write out a sample makefile, but there are rules that need to be followed in the formatting of them that makes it difficult to type in the editor window.

# Sample Makefile
CFLAGS := $(shell pkg-config --cflags glib-2.0 gtk+-2.0)
LDFLAGS := $(shell pkg-config --libs glib-2.0 gtk+-2.0)

foo: foo.c

This defines a simple rule saying to make foo, it depends on foo.c, so of foo.c is newer than foo, it will be rebuilt. Where I write 'TAB HERE NOT SPACES' it must be a tab character, and cannot be a set of space characters.

share|improve this answer
add comment

type "locate glib.h" to determine file's location (assuming a contemporary linux distribution - your post doesn't provide much information).

Then ensure the path to glib.h is properly specified in your Makefile. (You do have a Makefile, don't you?) Perform the same steps for gtk.h.

share|improve this answer
sir what is make file ?? –  tariq Mar 11 '11 at 19:32
add comment

Please read the official documentation. It explains how to compile GTK applications. Basically to compile a hello.c file to generate a hello program, you'll type:

share|improve this answer
add comment

Your Answer


