//test.c
#include <stdio.h>
#include "tool.h"
int main()
{
printf("add=%d\n",add(2,6));
return 0;
}
//tool.c
#include "tool.h"
int add(int a,int b)
{
int c=a+b;
return c;
}
//tool.h
#ifndef _TOOL_H_
#define _TOOL_H_
int add(int a,int b);
#endif
Makefile
test.exe: all
gcc -o test.exe test.o tool.o
all: test.o tool.o
clean:
rm *.o
rm *.exe
然后
make
make clean即可。