我正在使用egpgm来创建一个make文件。
http://mrbook.org/tutorials/make/我的文件夹eg_make_creation包含以下文件,
desktop:~/eg_make_creation$ ls
factorial.c functions.h hello hello.c main.c Makefile
Makefile
all:gcc -c main.c hello.c factorial.c -o hello
错误:desktop:~/eg_make_creation$ make all
make: *** No rule to make target `gcc', needed by `all'. Stop.
请帮助我理解如何编译这个程序
makefiles的语法非常严格:
target:dependencies
build_rules
# ^ this space here _needs_ to be a tab.
你所写的使all
依赖于gcc
, -c
,…
你需要的是:
all: hello
hello: factorial.c functions.h hello.c main.c
gcc -o hello factorial.c hello.c main.c
(如果你想编译和链接在一个步骤,不要使用-c
开关)
Mat钉住了。
在我的特殊情况下,我使用vi并默认启用expandtab !!
查看这个问题是否适用于您,打开vi并执行:
:set list
如果你在tab应该出现的地方没有看到^I,那么你很可能已经启用了et。
禁用它:
:set expandtab!
也许对别人也有帮助。
另一个原因是源文件列表中的名称错误。(nameWrong。这就是我的问题。
After all:
一切都是目标,显示依赖关系在那之后写的任何东西都应该显示该目录,就像在你的代码gcc
(作为一个文件不存在),就像-c
一样all:gcc -c main.c hello.c factorial.c -o hello
正确的一个是all:main.c hello.c factorial.c -o hello
GNU MAKE