There are easy to follow GTK+ 2.0 tutorials. I am learning by referring to the official gnome gtk+ tutorials and from zetcode.com
When compiling most often many of us newbies have got the error: "No such file or directory"
even if you have all the gnome-gtk-devel
and other required packages. Also you don't need to set any environment variables to make it work.
gcc: pkg-config --cflags --libs gtk+-2.0: No such file or directory
simple.c:1: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
If that's the case then just see what command you have entered. Most probably you might have entered:
gcc -Wall -g simple.c -o simple 'pkg-config --cflags --libs gtk+-2.0'
Note that the quote in which the
pkg-config
is written is '
character which is near the Enter
key. If so then that's the mistake. The character must be `
which is in the tilde (~
) key, above the Tab
key.So the correct way will be:
gcc -Wall -g simple.c -o simple `pkg-config --cflags --libs gtk+-2.0`
gcc -Wall -g simple.c -o simple $(pkg-config --cflags --libs gtk+-2.0)
It does the same thing, outputs the list of files, to be included and linked and likewise. To know more about that you can read the docs.