Makefile 的一个常见错误
因为工作需要,经常要写window 和 unix 系统兼容的程序。
可是,我在visual studio 2005 上写好Makefile 以后,放到freebsd
上,就是编译不了,报下面的错误:
make: fatal errors encountered -- cannot continue
我写了一个很简单的测试Make :
helloworld:main.o mylib.o
gcc main.o mylib.o -o helloworld
main.o:main.c mylib.h
gcc -c main.c -o main.o
mylib.o:mylib.c mylib.h
gcc -c mylib.c -o mylib.o
clean:
rm -rf *.o helloworld
可还是报:
"Makefile", line 2: Need an operator
"Makefile", line 5: Need an operator
"Makefile", line 8: Need an operator
"Makefile", line 11: Need an operator
make: fatal errors encountered -- cannot continue
想了半天,发现我设置了 visual studio 2005 tab as space,
也就是说,在我的visual studio 2005 上敲击 tab 键,自动会转换成space。
而上面的gcc 的前面需要一个tab 键。
如果,你有和我相同的问题,就要看看是不是 在你的编辑器上设置了 tab as space。