LinuxSir.cn,穿越时空的Linuxsir!

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

kernel module compile and insert

[复制链接]
发表于 2003-4-11 17:37:28 | 显示全部楼层 |阅读模式
我编了一个简单的内核模块
//helloworld.c

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

int init_module(void)
{
printk("<1>Hello World!\n");
return 0;
}


void cleanup_module(void)
{
printk("<1>Goodbye");
}


我用gcc编译如下:
gcc -c -DMODULE -D__KERNEL__ -DLINUX helloworld.c
结果如下:
helloworld.c:18:1: warning: no newline at end of file

然后插入模块:
insmod helloworld.o

结果如下:
helloworld.o: kernel-module version mismatch
helloworld.o was compiled for kernel version 2.4.9-9
while this kernel is version 2.4.18-14.

如果我用参数 -f强行加载
insmod -f helloworld.0


结果如下:

Warning: kernel-module version mismatch
helloworld.o was compiled for kernel version 2.4.9-9
while this kernel is version 2.4.18-14
Warning: loading helloworld.o will taint the kernel: no license
See http://www.tux.org/lkml/#export-tainted for information about tainted modules
Warning: loading helloworld.o will taint the kernel: forced load
Module helloworld loaded, with warnings


之所以没有出现<1>Hello World!是因为没有在真正的终端运行.


我的问题是如果不强行使用-f ,应该怎么办?



我的系统:
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
发表于 2003-4-11 20:06:23 | 显示全部楼层
你是不是升级过你的kernel,而没有升级你的kernel-source?
 楼主| 发表于 2003-4-11 23:31:06 | 显示全部楼层
我保证我的系统是刚装上的,redhat 8.0
一点都没有动
 楼主| 发表于 2003-4-12 19:19:49 | 显示全部楼层
那位高手知道?
发表于 2003-6-14 11:42:24 | 显示全部楼层
我也遇到这种情况,楼主解决了吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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