当前位置: 技术问答>linux和unix
最简单的内核模块,加载时提示version mismatch
来源: 互联网 发布时间:2015-11-02
本文导语: //编译和加载命令 [root@dev driver1]# gcc -c hello.c [root@dev driver1]# insmod hello.o hello.o: kernel-module version mismatch hello.o was compiled for kernel version 2.4.20 while this kernel is version 2.4.20-8. [root@dev...
//编译和加载命令
[root@dev driver1]# gcc -c hello.c
[root@dev driver1]# insmod hello.o
hello.o: kernel-module version mismatch
hello.o was compiled for kernel version 2.4.20
while this kernel is version 2.4.20-8.
[root@dev driver1]#
//源代码
/*++
hello.c
--*/
#define MODULE
#include
int
init_module()
{
int v1 = 100;
int *p = &v1;
printk("Hello, world this is the kernel speakingn");
printk("Address of p = %08xn",p );
return 0;
}
void
cleanup_module()
{
printk("Short is the life of a kernel modulen");
}
怎样改变编译的版本.谢谢.呵呵
[root@dev driver1]# gcc -c hello.c
[root@dev driver1]# insmod hello.o
hello.o: kernel-module version mismatch
hello.o was compiled for kernel version 2.4.20
while this kernel is version 2.4.20-8.
[root@dev driver1]#
//源代码
/*++
hello.c
--*/
#define MODULE
#include
int
init_module()
{
int v1 = 100;
int *p = &v1;
printk("Hello, world this is the kernel speakingn");
printk("Address of p = %08xn",p );
return 0;
}
void
cleanup_module()
{
printk("Short is the life of a kernel modulen");
}
怎样改变编译的版本.谢谢.呵呵
|
修改/usr/include/linux/version.h中的
#define UTS_RELEASE "2.4.20-8custom"为你的内核版本,uname -r
这个问题问得人很多了,你可以先搜一下。
#define UTS_RELEASE "2.4.20-8custom"为你的内核版本,uname -r
这个问题问得人很多了,你可以先搜一下。
|
ls正解
|
insmod -f XXX.o 强制装入,我现在就是这样的!