make:***没有规则来创建目标"gcc",这是"all"所需要的.停止 [英] make: *** No rule to make target `gcc', needed by `all'. Stop
本文介绍了make:***没有规则来创建目标"gcc",这是"all"所需要的.停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过一个pgm来创建一个make文件.
I am going through an eg pgm to create a make file.
http://mrbook.org/tutorials/make/
我的文件夹eg_make_creation包含以下文件,
My folder eg_make_creation contains the following files,
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.
请帮助我了解如何编译该程序.
Please help me understand to compile this program.
推荐答案
makefile的语法非常严格:
The syntax of makefiles is very strict:
target:dependencies
build_rules
# ^ this space here _needs_ to be a tab.
您写的内容使all
依赖于无效的目标gcc
,-c
,....
What you wrote makes all
depend on gcc
, -c
, ... which are not valid targets.
您需要的是类似的东西
all: hello
hello: factorial.c functions.h hello.c main.c
gcc -o hello factorial.c hello.c main.c
(如果要一步一步进行编译和链接,请不要使用-c
开关).
(If you want to compile and link in one step, don't use the -c
switch).
这篇关于make:***没有规则来创建目标"gcc",这是"all"所需要的.停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文