help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More on VPATH


From: Philip Guenther
Subject: Re: More on VPATH
Date: Mon, 20 Feb 2012 19:46:52 -0800

On Mon, Feb 20, 2012 at 7:25 PM, Bgh Ello <address@hidden> wrote:
>      Thanks for your help on my previous question, especially the comments
> on automatic rules.  I'll experiment with those in due course.  For now, I
> have added some include files.  hello.cpp and inc1.h are in dir1, and inc2.h
> in dir2.  The makefile is now
>
> VPATH = dir1 dir2
> CC = g++
> OPTS = -c -O2 -Wall
> OBJS = hello.o
>
> hello : $(OBJS)
>       $(CC) -o $@ $(OBJS)
>
> hello.o : hello.cpp inc1.h inc2.h
>         $(CC) $(OPTS) $< -o $@
>
> and the output of make is now
>
> g++ -c -O2 -Wall dir1/hello.cpp -o hello.o
> dir1/hello.cpp:6:18: fatal error: inc2.h: No such file or directory
> compilation terminated.
> make: *** [hello.o] Error 1
>
> I don't understand why make doesn't find the prerequisite dir2/inc2.h.
> Any help would be most appreciated.

Make found it just fine; the error message was from the compiler, g++.

You've told make where to look for the files; perhaps you should also
tell g++ where to look by passing it some -I options?

OPTS += $(VPATH:%=-I%)


Philip Guenther



reply via email to

[Prev in Thread] Current Thread [Next in Thread]