按照https://blog.csdn.net/yc461515457/article/details/50907393(gcc入门学习指导)来学习gcc,在建立Makefile文件以及make命令时出现了报错
CC=gcc
CFLAGS=-Wall
hello: hello.o hello_fn.o
clean:
rm -f hello hello.o hello_fn.o
make后提示报错信息为:makefile:6: *** missing separator。 停止。
经过查询这是为没有加tab导致的,于是在所有的语句前面加上了tab:
CC=gcc
CFLAGS=-Wall
hello: hello.o hello_fn.o
clean:
rm -f hello hello.o hello_fn.o
make后提示报错:makefile:3: *** recipe commences before first target。 停止。
经过查询这是因为多加了tab导致的。
本人也是十分的困惑,加不加tab都无法通过,最后在一片文章中找到了https://zhidao.baidu.com/question/534450991.html?fr=iks&word=%2A%2A%2A+missing+separator.&ie=gbk,只需要在命令行前面加tab就可以了,Makefile内容改为:
CC=gcc
CFLAGS=-Wall
hello: hello.o hello_fn.o
clean:
rm -f hello hello.o hello_fn.o
结果编译通过
chentingwei@chentingwei-virtual-machine:~/桌面$ make
gcc -Wall -c -o hello.o hello.c
gcc -Wall -c -o hello_fn.o hello_fn.c
gcc hello.o hello_fn.o -o hello
记录下这个错误