1 Makefile
就这样理解,帮我们对程序进行编译,我们每次gcc g++啥的很麻烦
2 举例子
我这里有3个文件first.c second.c third.c
first.c文件如下
#include <stdio.h>
int add(int a, int b)
{return a;
}
second.c文件如下
int sub(int a, int b)
{return a - b;
}
third.c文件如下
int main()
{int sum = add(1, 2);printf("sum is %d\n", sum);int sub = sub(5, 1);printf("sub is %d\n", sub);return 0;
}
我们编写Makefile文件,一点要注意这里的名字一定是大写开头,叫Makefile
all:test
first.o:first.cgcc -c first.c -o first.o
second.o:second.cgcc -c second.c -o second.o
third.o:third.cgcc -c third.c -o third.o
test:first.o second.o third.ogcc -o test first.o second.o third.o
没有写完,下次在写。