X-Spam-Check-By: sourceware.org Date: Fri, 20 Jan 2006 17:28:24 -0500 (EST) From: Igor Peshansky Reply-To: cygwin AT cygwin DOT com To: Eric Lilja cc: cygwin AT cygwin DOT com Subject: Re: Make things it's time to link when it should compile In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Fri, 20 Jan 2006, Eric Lilja wrote: > Hello, I'm having trouble with make for one simple program. > mikael AT mindcooler ~/coding/C/extract_acodes > $ ls -al > total 33K > drwxrwxrwx+ 2 mikael None 0 Jan 20 22:15 ./ > drwxrwxrwx+ 22 mikael None 0 Dec 7 16:12 ../ > -rwxrwxrwx 1 mikael None 264 Oct 14 13:54 Makefile* > -rw-r--r-- 1 mikael None 25K Jan 20 22:15 cygcheck.out > -rwxrwxrwx 1 mikael None 1.7K Oct 14 14:03 extract_acodes.c* > > mikael AT mindcooler ~/coding/C/extract_acodes > $ cat Makefile > CC = gcc > CFLAGS = -Wall -W -ansi -pedantic -g -O0 -c -o > LDFLAGS = -o $(EXEC) > EXEC = extract_acodes.exe > OBJECTS = extract_acodes.o > > all: $(OBJECTS) > $(CC) $^ $(LDFLAGS) > > %.o: %.c > $(CC) $(CLFAGS) $@ $< > > clean: > rm -f $(OBJECTS) $(EXEC) *~ *.stackdump > > mikael AT mindcooler ~/coding/C/extract_acodes > $ make > gcc extract_acodes.o extract_acodes.c > gcc: extract_acodes.o: No such file or directory > make: *** [extract_acodes.o] Error 1 > > Compiling and linking the program manually works just fine: > $ gcc -Wall -W -ansi -pedantic -g -O0 -c extract_acodes.c > > mikael AT mindcooler ~/coding/C/extract_acodes > $ gcc extract_acodes.o -o extract_acodes.exe > > But when I try to use the make, it seems to think it's time for the > final linking stage...and it's just a problem with this particular > "project". Any ideas what's wrong? I'm sure the Makefile is the culprit, > but I can't see the error. cygcheck.out attached (I would have used > cygwin 1.5.19-4 but I couln't find it on my local mirrors yet). Actually, make does exactly what you told it to do in line 11: invoke gcc with the empty value (of an uninitialized CLFAGS variable) after it, followed by the object file target, followed by the prerequisite source file. That's not a linking step. FWIW, you'd have the same exact trouble on Linux. For that reason, the "-o" option usually isn't part of CFLAGS. Aside from fixing the typo, I'd rewrite your Makefile as follows: $ cat Makefile CC = gcc CFLAGS = -Wall -W -ansi -pedantic -g -O0 LDFLAGS = EXEC = extract_acodes.exe OBJECTS = extract_acodes.o all: $(OBJECTS) $(CC) $(LDFLAGS) -o $(EXEC) $^ $(LDLIBS) %.o: %.c $(CC) $(CLFAGS) -c -o $@ $< clean: rm -f $(OBJECTS) $(EXEC) *~ *.stackdump $ Considering that most of your actions directly reflect the implicit make rules anyway, I'd even go for $ cat Makefile CC = gcc CFLAGS = -Wall -W -ansi -pedantic -g -O0 LDFLAGS = EXEC = extract_acodes.exe OBJECTS = extract_acodes.o all: $(EXEC) $(EXEC): $(OBJECTS) clean: rm -f $(OBJECTS) $(EXEC) *~ *.stackdump $ HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com ZZZzz /,`.-'`' -. ;-;;,_ Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte." "But no -- you are no fool; you call yourself a fool, there's proof enough in that!" -- Rostand, "Cyrano de Bergerac" -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/