我在为5个c程序创建makefile时遇到麻烦。我现在每个c程序都能够独立编译,但是当我尝试制作一个makefile时,运行make时出现此错误
Makefile:2: *** missing separator. Stop.
我试图放入makefile中的文件名是first.c,second.c,third.c,fourth.c和fifth.c。到目前为止,这是我的makefile所拥有的:
program: first.o second.o third.o fourth.o fifth.o
gcc -o program first.o second.o third.o fourth.o fifth.o
first.o: first.c
gcc -c first.c
second.o: second.c
gcc -c second.c
third.o: third.c
gcc -c third.c
fourth.o: fourth.c
gcc -c fourth.c
fifth.o: fifth.c
gcc -c fifth.c
最佳答案
这是应该如何格式化的:
all: first second third fourth fifth
first: first.c
gcc -o first first.c
second: second.c
gcc -o second second.c
third: third.c
gcc -o third third.c
fourth: fourth.c
gcc -o fourth fourth.c
fifth: fifth.c
gcc -o fifth fifth.c
关于c - 为多个C文件创建一个makefile,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48818329/