【问题标题】:"Nothing to be done for makefile" message“makefile 无需执行任何操作”消息
【发布时间】:2011-08-14 18:27:44
【问题描述】:

我有以下文件:

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'.

我不明白怎么了...

【问题讨论】:

  • 为什么顶部有makefile:?删除它!
  • 提示:尝试制作“全部”目标。
  • make -f makePractice Child 也许?

标签: c makefile


【解决方案1】:

如果您没有在命令行中指定目标,Make 默认使用在 makefile 中定义的第一个目标。在你的情况下,那是makefile:。但这无济于事。所以只需删除makefile:

【讨论】:

  • 如此简单!我爱你堆栈溢出! :D
  • 感谢您节省我的时间.. +1
【解决方案2】:

你的命令行没有告诉make你想要做什么,所以它默认尝试在makefile中创建第一个明确命名的目标。恰好是makefile,在第一行。

制作文件:

由于没有依赖关系,因此没有理由重新制作该文件。因此make 退出,很高兴遵从你的意愿。

【讨论】:

    猜你喜欢
    • 2019-02-03
    • 1970-01-01
    • 2015-05-19
    • 2014-02-17
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    • 1970-01-01
    • 2020-07-11
    相关资源
    最近更新 更多