I create C software using the SDL and GTK + 3 library. My first attempt with GTK + 3 on a specific main.c and its Makefile works fine, but when I try to add my GTK project to another piece of code using my "real "Makefile, even if I added the same flags for GTK +3, I cannot compile and get the gtk/gtk.h file no found error. I visited a lot of threads about this error, but I still can't get this to work.
Here is my old Makefile making it work:
CC=clang CPPFLAGS= `pkg-config --cflags gtk+-3.0` CFLAGS= -Wall -Wextra -std=c99 -O2 LDFLAGS= LDLIBS= `pkg-config --libs gtk+-3.0` `pkg-config gmodule-2.0 --libs` SRC= main.c OBJ= ${SRC:.c=.o} all: main main: ${OBJ} -lm clean: rm -f *~ *.o main
And here is the one I use for the project:
CC=clang CPPFLAGS= `pkg-config --cflags sdl gtk+-3.0` CFLAGS= -Wall -Wextra -Werror -std=c99 -O2 -pedantic LDFLAGS= LDLIBS= `pkg-config --libs sdl` `pkg-config --libs gtk+-3.0` `pkg-config gmodule-2.0 --libs` -lgtk -lgdk -lglib -lX11 -lXext -lSDL -lSDL_image -lm SRCDIR = src OBJDIR = obj BINDIR = bin TARGET = main SOURCES := $(wildcard $(SRCDIR)/*.c) INCLUDES := $(wildcard $(SRCDIR)/*.h) DEPENDS := $(wildcard $(OBJDIR)/*.d) OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o) rm = rm -f all: makedirs $(BINDIR)/$(TARGET) $(BINDIR)/$(TARGET): $(OBJECTS) @$(CC) $(OBJECTS) $(LDLIBS) -o $@ @echo "Linking complete!" $(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c @$(CC) $(CFLAGS) -c $< -o $@ @echo "[OK] Compiled "$<"" makedirs: @mkdir -p $(OBJDIR) @mkdir -p $(BINDIR) @echo "[OK] Created directories : $(BINDIR) $(OBJDIR)" [....] etc
And the error:
src/main.c:2:14: fatal error: 'gtk/gtk.h' file not found
Tanks for attention :)
[EDIT]
~ ▶ pkg-config --libs gtk+-3.0 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 ~ ▶ pkg-config --cflags sdl gtk+-3.0 -D_GNU_SOURCE=1 -D_REENTRANT -pthread -I/usr/include/SDL -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
And the main.c header:
#include <gtk/gtk.h> #include <stdio.h> #include <stdlib.h> #include "neural.h"
source share