【问题标题】:Makefile: make run commandMakefile:制作运行命令
【发布时间】:2017-03-09 15:22:56
【问题描述】:

这是我的makefile。我知道有一种更短的方法可以写出来,但我有一个关于如何运行它的问题。我的硬件说我必须使用命令: make run --- 这个命令应该导致可执行文件使用文件重定向来运行以读取输入文件数据。

我将如何进行设置?

我也知道 gcc 应该是标签页。

test:  main.o sum.o stack.o bSearch.o database.o db.o set.o parse.o bubble.o
    gcc -o object main.o sum.o stack.o bSearch.o db.o set.o parse.o bubble.o

main.o: main.c sum.h
gcc -c main.c

sum.o: sum.c sum.h
    gcc -c sum.c

stack.o: stack.c stack.h
    gcc -c stack.c

bSearch.o: bSearch.c defs.h sortAndsearch.h
    gcc -c bSearch.c

database.o: database.c defs.h parse.h
    gcc -c database.c

db.o: db.c defs.h
    gcc -c db.c

set.o: set.c set.h db.h
    gcc -c set.c

parse.o: parse.c parse.h
    gcc -c parse.c

bubble.o: bubble.c defs.h
    gcc -c bubble.c

sortAndsearch.h: db.h

defs.h: set.h sortAndsearch.h

stack.h: set.h

clean:
    rm *.o object

【问题讨论】:

  • 哪一部分你不知道怎么做?
  • 让它运行。当我输入 make run 时,它说没有规则让目标运行
  • 尝试只输入makemake test

标签: c makefile


【解决方案1】:

"run" 就像 Makefile 中的任何其他目标一样,例如 "test" 或 "set.o" - 但您必须将规则添加到 Makefile 以便 make 知道如何处理它。

run:
  ./test < input.txt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-23
    • 2020-12-30
    • 2012-09-20
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2019-03-08
    相关资源
    最近更新 更多