views:

141

answers:

4

i have this makefile below and in it my includes are

gtk/gtk.h

and

webkit/webkit.h

but when i try to build the project using the make command i have the errors

error: gtk/gtk.h: No such file or directory

error: webkit/webkit.h: No such file or directory

in case the gtk+-2.0.pc and webkit...pc are in the usr/lib/pkgconfig

Make File:

CC=gcc
CFLAGS=-g -Wall `pkg-config --cflags gtk+-2.0 webkit-1.0`
LDFLAGS+=`pkg-config --libs gtk+-2.0 webkit-1.0`
INCLUDE=/usr/include
LIB=/usr/lib
SOURCES=wrapper.c wrapper.h browser.c
OBJ=browser

all:  $(SOURCES) $(OBJ)

$(OBJ): $(SOURCES)
 $(CC) $(CFLAGS) $(LDFLAGS) -I $(INCLUDE) -L $(LIB) $(SOURCES) -o $(OBJ)

clean:
 rm -rf $(OBJ)
+1  A: 

Try setting CXXFLAGS in addition to CFLAGS.

Michael Daum
Actually, CXXFLAGS is for the C++ compiler. Maybe you mean CPPFLAGS? http://stackoverflow.com/questions/495598/difference-between-cppflags-and-cxxflags-in-gnu-make
Dave Bacher
+5  A: 

Backticks aren't how you run shell commands in a Makefile. Your CFLAGS and LDFLAGS lines should probably look like

CFLAGS=-g -Wall $(shell pkg-config --cflags gtk+-2.0 webkit-1.0)
LDFLAGS+=$(shell pkg-config --libs gtk+-2.0 webkit-1.0)
jamessan
While you are correct you need `$(shell ...)` to get the command to run in the Makefile, there is nothing wrong with using backticks. With backticks, make will pass the command lines with the backtick to the shell and the shell will handle that before invoking the compiler.
R Samuel Klatchko
there is no changes are got up
there is no wrong in the make file the error is in the system environment so who can i change it to have it run
@R Samuel Klatchko: You're correct. I forgot about that behavior.
jamessan
Also, using `$(shell ...)` instead of backticks means that pkg-config is only called twice (once for CFLAGS and once for LDFLAGS), instead of twice for every invocation of `$(CC)`.
jamessan
+1  A: 

The only include path you have specified is /usr/include, therefore it will look fo rthe files at:

/usr/include/gtk/gtk.h
/usr/include/webkit/webkit.h

Unless you have additional paths specifies in the either of the CPATH, or C_INCLUDE_PATH environment variables.

Add usr/lib/pkgconfig as a -I path.

Clifford
`$(CFLAGS)` contains additional `-I` directives as returned from pkg-config which will specify where to find the gtk and webkit headers.
jamessan
@jamessan: Except if that had worked and the files were present, it would have found them, so to add it manually is a useful investigation if not a permanent solution.
Clifford
+1  A: 

Do you actually have gtk/gtk.h and webkit/webkit.h in /usr/include directory? Are the development packages providing them installed?

Dmitry Yudakov
Yes, i have this files under the include dir
Having /usr/include/gtk/gtk.h and /usr/include/webkit/webkit.h and having changed \`...\` to $(shell ...) you should not have a problem, this makefile works with this change.
Dmitry Yudakov