"Nichts zu machen für makefile" - Meldung
Habe ich die folgenden Dateien:
Kind.c , Cookie.c , Cookie.h , CookieMonster.c , Glas.c , Glas.h-Milch.c , Milch.h
und das folgende makefile namens makePractice, die Sie ausführen soll, erstellen Sie zwei ausführbare Dateien, Kind und CookieMonster.
makefile:
CC = gcc # the compiler
CFLAGS = -Wall # the compiler flags
ChildObjects = Jar.o # object files for the Child executable
CookieMonsterObjects = Jar.o Milk.o #object files for the CookieMonster executable
all: Child CookieMonster # the first target. Both executables are created when
# 'make' is invoked with no target
# general rule for compiling a source and producing an object file
.c.o:
$(CC) $(CFLAGS) -c $<
# linking rule for the Child executable
Child: $(ChildObjects)
$(CC) $(CFLAGS) $(ChildObjects) -o Child
# linking rule for the CookieMonster executable
CookieMonster: $(CookieMonsterObjects)
$(CC) $(CFLAGS) $(CookieMonsterObjects) -o CookieMonster
# dependance rules for the .o files
Child.o: Child.c Cookie.h Jar.h
CookieMonster.o: CookieMonster.c Cookie.h Jar.h Milk.h
Jar.o: Jar.c Jar.h Cookie.h
Milk.o: Milk.c Milk.h
Cookie.o: Cookie.c Cookie.h
# gives the option to delete all the executable, .o and temporary files
clean:
rm -f *.o *~
Wenn ich versuche mit dem makefile zum erstellen der ausführbaren Dateien verwendet, indem Sie die folgende Zeile in der shell
make -f makePractice
Bekomme ich folgende Meldung:
make: Nothing to be done for `makefile'.
Ich verstehe nicht, was falsch ist...
- Warum haben Sie
makefile:
an der Spitze? Entfernen Sie das! - Hinweis: Versuchen Sie zu machen die "alle" - Ziel.
make -f makePractice Child
vielleicht?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Wenn Sie nicht angeben, ein Ziel, auf der Befehl-Linie, Machen nutzt ist das erste Ziel definiert im makefile standardmäßig. In deinem Fall ist
makefile:
. Aber das macht nichts. So entfernen Siemakefile:
.Deine Befehlszeile nicht sagen
make
was Sie wollen gemacht werden, so wird standardmäßig versucht, um das erste explizit als Ziel in der makefile. Das passiert zurmakefile
auf die erste Zeile.Da gibt es keine Abhängigkeiten, es gibt keinen Grund, alles zu tun, um ein remake der Datei. Daher
make
beendet, freut sich, dass ich befolgte Ihren Wunsch.