打印
[嵌入式linux]

求助Makefile文件

[复制链接]
1829|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
nsnwz|  楼主 | 2007-5-23 15:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*maht.c文件*/
#include <stdio.h>
#include"first.h"
int main()
{
        printf("%d\n",sub(2,3)) ;
        printf("good!\n") ;
}

/*first.c文件*/
#include"first_first.h"
int sub(int a, int b)
{
        return first_add(a,b) ;
}

/*firstfirst.c文件*/
int first_add(int a, int b)
{
        return a+b ;
}

/*Makefile文件*/
all: math.o
math.o:math.c  first.o
        gcc -o math.o math.c first.o
first.o:first.c firstfirst.c first_first.h
        gcc -c first.c  firstfirst.c
clean:
        \rm *.o

运行make,提示错误:first.o: In function `sub':first.c:(.text+0x14):对‘first_add’未定义的引用
collect2: ld 返回 1

请高手指教一 下,这个Makefile文件出错在那里。

相关帖子

沙发
nsnwz|  楼主 | 2007-5-23 16:58 | 只看该作者

高手指教

高手指教,急!

使用特权

评论回复
板凳
high| | 2007-5-24 01:42 | 只看该作者

.

/*first.c文件*/
#include"first_first.h"
extern int first_add(int a, int b);
int sub(int a, int b)
{
        return first_add(a,b) ;
}

使用特权

评论回复
地板
康飞等丝丝| | 2007-5-29 00:09 | 只看该作者

使用特权

评论回复
5
turmary| | 2007-5-30 02:46 | 只看该作者

可以这样儿

在first_first.h中加入
int first_add(int a, int b);

在firstfirst.c中加入
#include"first_first.h"

这样儿就是标准用法.定义与使用的地方均包含这个头文件.

使用特权

评论回复
6
frankfly| | 2007-6-3 19:22 | 只看该作者

应该要加路径吧

使用特权

评论回复
7
woyaya| | 2007-7-9 16:50 | 只看该作者

re

all: math.o
math.o:math.c  first.o
        gcc -o math.o math.c first.o <<<<<<<<<<<<<<<缺少first_first.o
first.o:first.c firstfirst.c first_first.h
        gcc -c first.c  firstfirst.c
clean:
        \rm *.o

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

11

主题

13

帖子

1

粉丝