您的位置:首页 > 其它

最简单的一个makefile实例

2016-12-12 22:59 323 查看
//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即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: