Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header files in subdirectories (e.g. gtk/gtk.h vs gtk-2.0/gtk/gtk.h)

I'm trying to build a hello world using GTK, which includes the line:

#include <gtk/gtk.h>

as you would expect.

The Makefile supplied has the line:

GTK_INCLUDE = -I/usr/local/include

so it would expect to find gtk.h in /usr/local/include/gtk/gtk.h. However on my system, it is located in /usr/local/include/gtk-2.0/gtk/gtk.h, ie within a version'ed subdirectory.

Obviously in this case I can add -I/usr/local/include/gtk-2.0 to the Makefile, but the same problem crops up with gtk.h's dependencies and so on.

Is there a good way of dealing with this? Could configure be used to locate where the header files are and add the appropriate include directories? I know next to nothing about configure, but it seems to find out things about the system at build time, which is what I am after.

Is this a common occurence or do I have some freak directory structure which is the real problem?

Thanks for any pointers!

like image 219
Ray2k Avatar asked Dec 09 '22 20:12

Ray2k


2 Answers

You need to use pkg-config to get the include paths:

$ pkg-config --cflags gtk+-2.0
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12

You must also use it to get the libraries:

$ pkg-config --libs gtk+-2.0
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lgio-2.0 -lcairo -lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

(The output of these commands will vary depending on your distribution, and will always be the correct ones for your distribution.)

like image 173
CesarB Avatar answered Mar 19 '23 02:03

CesarB


Probably, you must create a symbolic link like:

ln -s /usr/local/include/gtk /usr/local/include/gtk-2.0

but you can first try to reinstall the GTK package.

like image 21
bill Avatar answered Mar 19 '23 04:03

bill