This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Fri, Mar 15, 2002 at 10:17:28AM -0500, Rich wrote: > I'm new to gcc and am running Mandrake Linux 8.1 with gcc 2.96-0.62mdk. > > I've been experimenting with writing my own makefiles and have run into > a problem. The makefiles work OK as long as all of the source code is > in the same subdirectory, however, if the source is in another > subdirectory, the makefile can't find it. Here's a simple code sample: > > ------------------------------------------------- > CC = gcc > > all: simple > > vpath %.h ~/Projects/test/src > > simple.o: simple.c > $(CC) -c simple.c > > simple: simple.o > $(CC) -o simple simple.o > ------------------------------------------------------- > > The source code is in the /Projects/test subdirectory but simple.c has a > header file called foo.h that's in the /Projects/test/src subdirectory. > The error message is "No such file or directory called foo.h". Why > isn't it being found? VPATH= ~/Projects/test/src doesn't work either. > > What's missing? You don't use vpath for the c compiler/pre-processor. Instead, use the -I flag: CC = gcc CFLAGS = -I /some/other/directory %.o: %.c $(CC) $(CFLAGS) -c $< all: simple simple: simple.o $(CC) -o simple simple.o -- Kayvan A. Sylvan | Proud husband of | Father to my kids: Sylvan Associates, Inc. | Laura Isabella Sylvan | Katherine Yelena (8/8/89) http://sylvan.com/~kayvan | "crown of her husband" | Robin Gregory (2/28/92)
Attachment:
msg00119/pgp00000.pgp
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |