LinuxSir.cn,穿越时空的Linuxsir!

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

关于向内核加载模块时版本不匹配的问题

[复制链接]
发表于 2005-3-17 18:29:20 | 显示全部楼层 |阅读模式
各位高手,大家好。小弟初来乍到,有个问题想请好心人指点一二,感激万分。
在我将一简单模块加载时出现如下错误信息:
              [root@localhost pgs]# gcc -c hi.c
              [root@localhost pgs]# /sbin/insmod   hi.o
              hi.o: kernel-module version mismatch
                      hi.o was compiled for kernel version 2.4.20
                      while this kernel is version 2.4.20-8.
             下面是hi.c的源代码:
                  #define MODULE
                  #include <linux/module.h>
                     int init_module (void)
                    {
                      printk("<1>hello world!");
                    }
                    void cleanup_modile (void)
                    {
                     printk("<1>goodbye cruel world!");
                    }
             怎么才能使模块版本与内核版本一致而通过检验呢?
发表于 2005-3-18 00:31:32 | 显示全部楼层
hi.o 是在 kernel  2.4.20 下编译的。。所以通不过。。

应该在2.4.20-8下编译。。

上面提示说。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-18 15:10:29 | 显示全部楼层
可是内核版本是2.4.20-8, 而gcc -c hi.c命令的执行不正是在当前内核下么?
感谢! 北南南北
能再给些提示么?是什么在决定着模块的版本呢?
期待中。。。。。。。。
回复 支持 反对

使用道具 举报

发表于 2005-4-15 16:05:46 | 显示全部楼层
小弟也遇到了同样的问题,斑竹救我们啊~~
回复 支持 反对

使用道具 举报

发表于 2005-4-15 19:00:20 | 显示全部楼层
when building your linux kernel module (LKM), you need to declare MODULE and __KERNEL__.
By doing this, you let the compiler know that it is a LKM.
My suggestion is to add this line:
#define __KERNEL__
回复 支持 反对

使用道具 举报

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

本版积分规则

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