【问题标题】:Makefile clean all target is called twice when explicitly invokedMakefile clean all 目标在显式调用时被调用两次
【发布时间】:2014-06-06 10:42:43
【问题描述】:

我仍在弄清楚为什么在下面的 Makefile 中,当我在 ma​​ke clean all 之类的命令中执行它时,它会运行两次“clean all”目标部分?

FLAGS = -g -Wall -Wextra -Werror

a.out : check.cpp
    $(CXX) $(CFLAGS) -o $@ $< 

clean all:
    rm -rf *.o *.out *.txt

【问题讨论】:

    标签: makefile


    【解决方案1】:

    目标“clean all:”相当于:

    clean:
            rm -rf *.o *.out *.txt
    all:
            rm -rf *.o *.out *.txt
    

    目标名称中不能有空格,每个单词都将被视为目标。因此,当您执行make clean all 时,make 认为您想要构建目标“干净”和目标“全部”,因此您有 2 个正在执行的目标。它看起来确实像 makefile 中的一个错误,因为所有的操作都与 clean 相同是很奇怪的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-30
      • 2012-08-06
      • 2018-09-13
      相关资源
      最近更新 更多