help-make
[Top][All Lists]
Advanced

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

Re: Makefile


From: Philip Guenther
Subject: Re: Makefile
Date: Sat, 31 Jul 2010 21:01:40 -0700

On Sat, Jul 31, 2010 at 5:38 AM, Muhammad Bilal <address@hidden> wrote:
> There are five files
> (first.c (includes the main function), f1.c,f2.c f1.h and f2.h) in the 
> project. I want to write makefile such that it compiles only those files in 
> which changes are made... My makefile commands are:
>
> all: first
> fist: first.o f1.o f2.o
> gcc first.o f1.o f2.o -o first
> first.o: first.c f1.c f2.c
> gcc -Wall -c -o first.o first.c
> f1.o: f1.c f1.h
> gcc -Wall -c -o f1.o f1.c
> f2.o: f2.c f2.h
> gcc -Wall -c -o f2.o f2.c
>
>
> but the compiler gives me error that f1.h and f2.h not exist.

First of all, is that *really* what is in your makefile?  I ask,
because there's an obvious typo on the second line.  If that's your
makefile, then fix the misspelled "fist".  If that's *not* your
makefile, then I tell you that you should *NEVER* retype stuff that
you're asking out in email!  *Always* cut-and-paste instead!

That said, you don't give us enough data to debug the problem.  Please
cite the actual make output, including the compiler error message(s)
when reporting an error.  Without that, we'll just be guessing.
Including (by cut-n-paste!) the output of 'ls -l' showing that the
directory includes all the involved files would help.

And finally, your makefile is really not in a 'normal' style.  The
normal style uses variables and rules to avoid repeating stuff, and
thereby avoid the possibility of typos or errors.


Philip Guenther



reply via email to

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