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!
You need to use
pkg-config
to get the include paths:You must also use it to get the libraries:
(The output of these commands will vary depending on your distribution, and will always be the correct ones for your distribution.)
Probably, you must create a symbolic link like:
but you can first try to reinstall the GTK package.
I haven't used gtk in a long while, but the way this is normally handled in Linux is that there is a script called packagename-config (in this case, probably gtk-config) that comes with the development headers, which your makefile is supposed to call in order to get the proper include paths and linker flags for the package, using --cflags and --libs respectively.
So try something like
(note the use of backticks, not apostrophes)
And you probably also want to add the output of
gtk-config --libs
to your LDFLAGS in order to make sure you are linking against all the right stuff.