首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"Nothing to to for makefile“消息

"Nothing to to for makefile“消息
EN

Stack Overflow用户
提问于 2011-08-15 02:27:44
回答 2查看 44.6K关注 0票数 13

我有以下文件:

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

以及下面的makefile,名为makePractice,它将创建两个可执行文件ChildCookieMonster

代码语言:javascript
复制
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中运行以下行

代码语言:javascript
复制
make -f makePractice

我得到以下消息:

代码语言:javascript
复制
make: Nothing to be done for `makefile'.

我不明白出了什么问题..。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-15 02:30:49

如果没有在命令行上指定目标,Make默认使用makefile中定义的第一个目标。在您的例子中,就是makefile:。但这并不能解决任何问题。所以只要删除makefile:就行了。

票数 15
EN

Stack Overflow用户

发布于 2011-08-15 02:32:23

您的命令行不会告诉make您想要创建什么,所以它默认尝试在makefile中创建第一个显式命名的目标。这恰好是makefile,在第一行。

生成文件:

由于没有依赖项,因此没有理由执行任何操作来重新生成该文件。因此,make退出了,很高兴满足了您的愿望。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7058805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档