这样的makefile应该怎么写?

yuzcsdn 2003-07-19 01:37:13
/******** 1.h ********/
#ifndef STDIO_H
#include <stdio.h>
#endif
void display2(int a,int b);

/******** 1.c ********/
void display2(int a,int b)
{
printf("one:%d\ttwo=%d\n",a,b);
}

/******** 2.h ********/
#include "1.h"
int swap(int *a,int *b);

/******** 2.c ********/
int swap(int *a,int *b)
{
int temp;

display2(*a,*b);
temp=*a;
*a=*b;
*b=temp;
display2(*a,*b);
}

/******** main.c ********/
#include "2.h"

int main()
{
int k,j;
k=10;j=100;
swap(&a,&b);
return 0;
}

我看了些资料,但还是对依赖关系不太清楚,哪位能给个上头的makefile例子?
谢谢!
...全文
35 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuzcsdn 2003-07-21
  • 打赏
  • 举报
回复
有没有人愿意指导一下!
yuzcsdn 2003-07-19
  • 打赏
  • 举报
回复
to xpdavis(咕嘟):
多谢!
不过我对你写的有些疑问:
unit1: 1.c
cc -c 1.c
不用包含.h 吗?
unitmain: main.c 1.o 2.o
cc -o execfile main.c
上一条的目标是 unit[1,2],这里写的2.o ?
还有2.o怎么知道啊,跟踪源文件?那可比较累
总之make不过,报错undefined reference 'swap'


铖邑 2003-07-19
  • 打赏
  • 举报
回复
unit1: 1.c
cc -c 1.c

unit2: 2.c
cc -c 2.c

unitmain: main.c 1.o 2.o
cc -o execfile main.c

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧