gpt4 book ai didi

c - "Nothing to be done for makefile"消息

转载 作者:太空狗 更新时间:2023-10-29 16:38:02 24 4
gpt4 key购买 nike

我有以下文件:

Child.c、Cookie.c、Cookie.h、CookieMonster.c、Jar.c、Jar.h、Milk.c、Milk.h

和以下名为 makePractice 的 makefile,它应该创建两个可执行文件,ChildCookieMonster

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 *~

当我尝试使用 makefile 创建可执行文件时,通过在 shell 中运行以下行

make -f makePractice

我收到以下消息:

make: Nothing to be done for `makefile'.

我不明白这是怎么回事...

最佳答案

如果您没有在命令行中指定目标,Make 默认使用 makefile 中定义的第一个目标。在您的例子中,它是 makefile:。但这没有任何作用。所以只需删除 makefile:

关于c - "Nothing to be done for makefile"消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7058805/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com