Reputation: 55
I'm trying to compile a GTK program on my Debian desktop. I installed libgtk-3-dev and all of that, but when I go to compile the program, I get this error:
$ gcc -o client client.c `pkg-config --cflags --libs glib-2.0`
client.c:6:10: fatal error: gtk/gtk.h: No such file or directory
6 | #include <gtk/gtk.h>
| ^~~~~~~~~~~
compilation terminated.
All of the GTK headers actually seem to be in /usr/include/gtk-3.0
, but even if I include <gtk-3.0/gtk/gtk.h>
I get errors, since the files inside include other GTK headers as if they were in a normal include path. Then if I compile with -I/usr/include/gtk-3.0
I still get errors, this time about glib. Well, glib files are inside /usr/include/glib-2.0
and it's the same problem as before. Finally, if I compile with -I/usr/include/gtk-3.0 -I/usr/include/glib-2.0
, I this time get this error:
$ gcc -o client -I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 client.c `pkg-config --cflags $ --libs glib-2.0`
In file included from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from client.c:6:
/usr/include/gtk-3.0/gdk/gdktypes.h:35:10: fatal error: pango/pango.h: No such file or directory
35 | #include <pango/pango.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
Seems like any combination of compile flags I choose, I get some sort of error, all caused by Debian putting the headers in a non-standard subdirectory. This is not me messing with them, this is what apt installs for me.
Upvotes: 0
Views: 935
Reputation: 1012
You are asking pkg-config
for glib, you must ask pkg-config
for the GTK+ library:
gcc -o client client.c `pkg-config --cflags --libs gtk+-3.0`
You can keep glib-2.0
in the command line, but since GTK+ depends on glib, it's already included.
Upvotes: 2