LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1229|回复: 1

自己写的module makefile貌似不对 WARNING: "xiao" [/root/test1

[复制链接]
发表于 2008-6-10 14:48:06 | 显示全部楼层 |阅读模式
test1.c:

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>

#include "xiao.h"

MODULE_DESCRIPTION("My kernel module");
MODULE_AUTHOR("root (root@localhost.localdomain)");
MODULE_LICENSE("$LICENSE$");

static int test1_init_module(void)
{
    int a=3,b=5;
    int res;
        printk( KERN_DEBUG "Module test1 init\n" );
        res=xiao(a,b);
        printk( KERN_DEBUG "Module test1 init  res=%d \n", res);
        return 0;
}

static void test1_exit_module(void)
{
        printk( KERN_DEBUG "Module test1 exit\n" );
}

module_init(test1_init_module);
module_exit(test1_exit_module);

****************

xiao.c:
int xiao(int a,int b)
{
  int c=a+b;
  return(c);
}

***************
#ifndef _XIAO_H_
#define _XIAO_H_

int xiao(int a,int b);

#endif

**********

makefile:
TARGET = test1
OBJS = test1.o xiao.o
MDIR = drivers/misc

EXTRA_CFLAGS = -DEXPORT_SYMTAB
CURRENT = $(shell uname -r)
KDIR = /lib/modules/$(CURRENT)/build
PWD = $(shell pwd)
DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)

#obj-m      := $(TARGET).o
$(TARGET).o-objs:=test1.o xiao.o
obj-m = $(TARGET).o

default:
        make -C $(KDIR) SUBDIRS=$(PWD) modules

$(TARGET).o: $(OBJS)
        $(LD) $(LD_RFLAG) -r -o $@ $(OBJS)

ifneq (,$(findstring 2.4.,$(CURRENT)))
install:
        su -c "cp -v $(TARGET).o $(DEST) && /sbin/depmod -a"
else
install:
        su -c "cp -v $(TARGET).ko $(DEST) && /sbin/depmod -a"
endif

clean:
        -rm -f *.o *.ko .*.cmd .*.flags *.mod.c

-include $(KDIR)/Rules.make

**************

编译时有警告:WARNING: "xiao" [/root/test1/test1.ko] undefined!
加载时就抱怨说有不识别的标志,加不上。

大家帮我看一下,这个要怎么改

谢谢!
发表于 2008-6-11 09:23:19 | 显示全部楼层
****************

xiao.c:

#include "xiao.h"
int xiao(int a,int b)
{
int c=a+b;
return(c);
}

***************

xiao.c  里面没有加上xiao.h
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表