LinuxSir.cn,穿越时空的Linuxsir!

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

新手添加第一个内核模块出错!

[复制链接]
发表于 2004-3-20 23:28:41 | 显示全部楼层 |阅读模式
我编写了一个hell.c 文件
如下:
#include<linux/kernel.h>
#include<linux/module.h>
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include<linux/modversions.h>
#endif
int init_module()
{
   printk("Hello,word-this is the kernel speaking\n");
   return 0;
}

void cleanup_module()
{
     printk("Short is the life of a kernel module\n");
}
Makefile文件如下:
CC=gcc
MODCFLAGS:= -Wall -DMODULE -D__KERNEL__ -DLINUX

hello.o:hello.c /usr/include/linux/version.h
        $(CC) $(MODCFLAGS) -c hello.c
        echo insmod hello.o to turn it on
        echo rmmod hello to turn if off
        echo
        echo X and kernel programming do not mix.
        echo Do the insmod and rmmod from outside X.
放在/usr下面输入gcc -c hello.c错误如下:
/usr/include/linux/module.h:In function 'print_symbol';
/usr/include/linux/module.h:433:'ESRCH'undeclared
当输入gmake错误如下:
gmake:gcc-Wall:Command not found.
gmake:***[hello.o]error 127
谢谢了先!:help :help
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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