我正在通过一个eg pgm 来创建一个make 文件。
http://mrbook.org/tutorials/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
error:
desktop:~/eg_make_creation$ make all
make: *** No rule to make target `gcc', needed by `all'. Stop.
请帮助我理解编译这个程序。
makefile 的语法非常严格:
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
转变)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)