[英]recipe for target 'all' failed on Ubuntu 15.10 64-bit
1) Program works well if I type each command on Terminal by gcc -o file1 file1.c && gcc file2.c -lm -o file2
, and then ./file1 someArgs ./file2 someArgs
1)如果我在终端上通过gcc -o
file1 file1.c && gcc file2.c -lm -o file2
然后在./file1 someArgs ./file2 someArgs
键入每个命令,程序运行良好
2) Also works if I type in Terminal: make rst and make res 2)如果我在Terminal中输入,也可以使用:make rst和make res
3) Not working by typing make
in Terminal 3)在终端中键入
make
不能正常工作
Makefile: Makefile文件:
all:
check
default:
check
clean:
rm -rf file1 file2
rst:
gcc -o file1 file1.c && gcc file2.c -lm -o file2
res:
./file1 someArgs ./file2 someArgs
check:
make clean
make rst
make res
Also tried: 还尝试了:
all:
check
default:
check
clean:
rm -rf file1 file2
rst:
gcc -o file1 file1.c && gcc file2.c -lm -o file2
res:
./file1 someArgs ./file2 someArgs
check:
clean
rst
res
And some other combinations with or without make
. 以及其他一些带有或不带有
make
组合。 All same error: 所有相同的错误:
make: check: Command not found
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 127
You seem to have some confusion between the prerequisites of a make rule and its recipe. 您似乎在make规则的前提条件及其配方之间有些混淆。 The prerequisites go on the same line as the target name;
前提条件与目标名称在同一行。 the recipe goes on the next tab-indented line or lines.
配方在下一个或多个制表符缩进的行上进行。 Thus, for example, this rule ...
因此,例如,此规则...
all:
check
... says that target 'all' has no prerequisites (so it is always considered out of date), and that the recipe for building it is to run a command check
. ...说目标'all'没有先决条件(因此总是被认为是过时的),并且构建目标的方法是运行命令
check
。 What you appear actually to want is to build the target named 'check', which you can cause to happen by making 'check' a prerequisite of 'all': 您实际上想要的是构建名为“ check”的目标,您可以通过将“ check”作为“ all”的先决条件来实现:
all: check
More generally, you seem to be approaching the makefile as if it were a program with multiple entry points, but it is much better viewed as a set of rules that make
can use to build things. 更一般地,你似乎是接近的makefile,好像它是具有多个入口点的程序 ,但它作为一组规则是更好的观察
make
可用于构建的东西。 Thus, it is conventional and desirable for rules that actually build a file to specify the built file as a target. 因此,对于实际构建文件的规则来说,将构建的文件指定为目标是常规且合乎需要的。 Moreover, to use the full power of
make
, you should express the proper prerequisites for those and other rules. 此外,要充分利用
make
,您应该为这些规则和其他规则表达适当的先决条件。 For example: 例如:
./file1: file1.c
gcc -o file1 file1.c
./file2: file2.c
gcc file2.c -lm -o file2
res: ./file1 ./file2
./file1 someArgs ./file2 someArgs
If you do that correctly then you don't need hacks such as removing and rebuilding the programs every time -- make
will figure out whether they are out of date, and will rebuild them if and when it needs to do. 如果你这样做正确,那么你就不需要黑客如删除,每次重建计划-
make
会弄清楚他们是否是过时的,并且如果当它需要做的将重建他们。
The first target all
is trying to run a command called check
(and so is the target default
). all
第一个目标all
试图运行一个称为check
的命令(目标default
)。 I think you want the command make
to behave the same as the command make check
and to perform the actions of the target called check
in the Makefile. 我认为您希望命令
make
的行为与命令make check
相同,并执行Makefile中名为check
的目标的动作。 In that case, add it as a dependency like this: 在这种情况下,将其添加为如下所示的依赖项:
all: check
default: check
clean:
rm -rf file1 file2
rst:
gcc -o file1 file1.c && gcc file2.c -lm -o file2
res:
./file1 someArgs ./file2 someArgs
check:
make clean
make rst
make res
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.