Compiler cannot find header file, do I add the directory to PATH

compilinggtkheader-filemakepath

I am trying to work with gtk which is located at /usr/include/gtk-3.0/gtk/ .., but all of the header files in the toolkit have #include <gtk/gtk.h>.

Aside from adding /usr/local/gtk-3.0 to PATH or adding gtk-3.0 to all the include preprocessors, what other options does one have with this?

Best Answer

Adding the appropriate directory to your include path is exactly what you're supposed to do in this case, only you're supposed to do it by pkg-config. Accessing the files directly using full pathnames is unsupported.

Add something like this to your Makefile:

CFLAGS += `pkg-config --cflags gtk+-3.0`
LIBS += `pkg-config --libs gtk+-3.0`

This will automatically add the correct compiler and linker options for the current system.

Related Question