>I have a file test.c that includes foo.h. Implementation for foo.h is in foo.c
What do you mean by "implementation for foo.h"? Does test.c use functions
that are defined in foo.c, and whose prototypes are in foo.h? I'll assume
below that this is what you mean.
Quote:>Is this the correct makefile
>********************
>test : test.o
> g++ -o test test.o
>test.o : test.c
> g++ -c test.c
>**************************
>Do I have to also compile foo.c ???
Yes. And you need to link it with test.o to create test. Your makefile
should be:
test: test.o foo.o
g++ -o test test.o foo.o
test.o: test.c foo.h
g++ -c test.c
foo.o: foo.c foo.h
g++ -c foo.c
The foo.o dependency on foo.h is needed if there are any structure or class
definitions in foo.h. If it just contains prototypes for the functions in
foo.c, you don't need that.
--
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.