|
发表于 2005-3-30 09:05:21
|
显示全部楼层
Post by jorson
:thank
插入2.6.5的内核模块的问题:
hello.c
#define MODULE
#define KERNEL
#include <linux/module.h>
int init_module(void){printk("<1>hello!world\n");return 0;}
void cleanup_module(void) {printk("<1>goodbye!world\n");}
编译hello.c通过:
root]#gcc -c hello.c
插入出错:
root]#insmod ./hello.o
insmod:error inserting './hello.o':-l(还是1??)Invalid module format
改写为:
hello.c
#define MODULE
#define __KERNEL__
#include <linux/module.h>
int init_module(void){printk("<1>hello!world\n");return 0;}
void cleanup_module(void) {printk("<1>goodbye!world\n");}
编译出错:
root]#gcc -c hello.c
In file include from /usr/include/linux/module.h:10,
from hello.c:3
/usr/include/linux/config.h:5.2: #error Incorrectly using glibc headers for a kernel module
谢谢
Makefile 应如下:
obj-m:=hello.o
default:
[tab]make -C /lib/modules/`uname -r`/build M=`pwd`
然后make就可以了 |
|