[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cant find *.h
Eyal Retter <DP13392@elbit.co.il> writes:
> when I use :
>
> all: xxx.o
> gcc -o xxx xxx.c -I/usr/X11R6/include -lXm -lXt -lX11
>
> I get the error : can't find Xm.h in xxx.c .
>
> but when I use:
>
> all: xxx.c
> gcc -o xxx xxx.c -I/usr/X11R6/include -lXm -lXt -lX11
>
> everything is ok. why ?
>
This is probably because in the first case the target "all" depends on
xxx.o, so make tries to build xxx.o first. It knows how to build xxx.o
from xxx.c, with something like
%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $<
(I didn't check, but it should be very close to the real default
rule), and -I/usr/X11R6/include is not a part of $(CPPFLAGS), so you
get that error message while building xxx.o, *not* while building
"all". In the second case "all" depends on xxx.c directly, so it goes
to the explicit rule that has the correct -I flag.
--
Oleg Goldshmidt goldshmt@netvision.net.il
BLOOMBERG L.P. (BFM) oleg@bfr.co.il