QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4556|回复: 16

kernel-module version mismatch

[复制链接]
发表于 2003-10-23 12:01:54 | 显示全部楼层 |阅读模式
在编译linux device drivers 中的hello.c 例子中,遇到kernel_module version mismatch,看了很多帖子。通过增加预编译指令和编译优化选项均不能解决。请问各位大侠是否必须编译内核,或重装gcc。我用的是redhat 9.0 kernel-2.4.20-8 在编译内核时一路照命令做下去重启后用的还是旧内核.请问是否有redhat 的其他版本不存在该问题。还有一点不懂redhat 的/usr/src下有debug redhat 选项,不是linux-kernelversion
不知如何重新编译redhat .请各位大侠指条明录。不胜感激
发表于 2003-10-23 18:59:33 | 显示全部楼层
http://www.linuxfans.org/nuke/modules.php?name=Forums&file=viewtopic&t=17245
回复

使用道具 举报

发表于 2003-10-29 02:19:57 | 显示全部楼层
just replace "2.4.20" in /usr/include/linux/modversions.h with "2.4.20-8".
回复

使用道具 举报

发表于 2003-10-29 02:27:46 | 显示全部楼层
that debug , redhat are not for kernel use. ignore it.
回复

使用道具 举报

发表于 2003-10-29 02:57:47 | 显示全部楼层
no need rebuiding your kernel or reinstalling gcc!(who told you to do that? )
回复

使用道具 举报

发表于 2003-10-29 03:08:16 | 显示全部楼层
i told them to recompile a kernel. that can save some troubles.

and i think recompiling kernel is a good practice before starting writing kernel module.

not sure who said that about gcc.  
回复

使用道具 举报

发表于 2003-10-29 03:10:17 | 显示全部楼层
Good evening!
回复

使用道具 举报

发表于 2003-10-29 03:11:01 | 显示全部楼层
Oh, no! I should say "Good morning!"
回复

使用道具 举报

发表于 2003-10-29 04:28:52 | 显示全部楼层
to yihe_guo:
if you REALLY  want to rebuild your kernel, please edit linux-2.4.22-8/Makefile, and leave the line "EXTRAVERSION = -8" blank(namely "EXTRAVERSION =").
回复

使用道具 举报

发表于 2003-10-29 04:36:08 | 显示全部楼层
I prefer the former--just add two char "-8"
回复

使用道具 举报

 楼主| 发表于 2003-10-29 13:32:59 | 显示全部楼层
多谢各位高手的指点,我修改了/usr/include/linux/version.h问题解决了,但有一点没想明白,到底kernel gcc版本问题是怎么回事,尽靠修改头文件会不会为以后带来隐患?
还有一个问题编写程序的头文件#include <linux/*> ,他的路经是在/usr/src/linux/include/linux还是/usr/include/linux 而且我发现里边文件数目不同,同一文件名的内容也不同,我想编写一个驱动程序模块,如何理解该问题?
回复

使用道具 举报

发表于 2003-10-29 15:59:31 | 显示全部楼层
[quote:ca478e60f5="yihe_guo"]多谢各位高手的指点,我修改了/usr/include/linux/version.h问题解决了,但有一点没想明白,到底kernel gcc版本问题是怎么回事,尽靠修改头文件会不会为以后带来隐患?
还有一个问题编写程序的头文件#include <linux/*> ,他的路经是在/usr/src/linux/include/linux还是/usr/include/linux 而且我发现里边文件数目不同,同一文件名的内容也不同,我想编写一个驱动程序模块,如何理解该问题?[/quote]

Your questions are very good! You think of the same questions as I once did.

1,"隐患"
At first, gcc is just a compiler and, as far as Compiling Principle is concerned, header     files are none business of the comiler(gcc) itself(at least to some extent), but of the C library(glibc). If you worry about it, and if you want to DIY all, I recommand a helpful way to you:
1. recompile your kernel: linux-x.y.z
2. recompile your glibc with options "--with-headers=/usr/src/linux-x.y.z/include"
3. when compiling kernel module, use the gcc option "-I/usr/src/linux-x.y.z/include" or simply, delete /usr/include/linux and asm, and link linux-x.y.z/linux and asm-i386 to there.

Still any "隐患"?

2."路经"
/usr/src/linux/include/(, with which your kernel was built !) is always proper.
回复

使用道具 举报

 楼主| 发表于 2003-10-29 19:21:01 | 显示全部楼层
thanks ,but i also have some questions for your answer
1.is it right that if i use the gcc option "-I/usr/src/linux-x.y.z/include" than i don't need to recompile my kernel and glibc?
2.if i want to recompile my kernel,how can i do it ?can you  give me some suggestion?
3.i think glibc is compiled for certion kernel.if i recompile your glibc with options "--with-headers=/usr/src/linux-x.y.z/include" ,it can be right for the kernel now running? it only includes some header files!
回复

使用道具 举报

发表于 2003-10-29 22:42:00 | 显示全部楼层
1, Quite right!
2. Considering that you are studying and developing device drivers, I recommend the linux 2.4.22  kernel. You can download it from ftp.kernel.org, and "make menuconfig->make clean->make bzImage->make modules->make modules_install->make install", and finally edit /etc/grub.conf(or lilo.conf) replace "root=LABEL=/" with "root=/dev/hdaX". OK, reboot ...
3. In most cases, I think, it can run properly. As a matter of fact, I have developed several ethernet adapter drivers but never met that problem.
  The option `--with-headers=DIRECTORY' is just specify the kernel header file, but not the comman C headers such as stdio.h. Glibc needs information from the kernel's private header files. Glibc will normally look in `/usr/include' for them, but if you specify this option, it will look in DIRECTORY instead.

Any question else ?
回复

使用道具 举报

发表于 2003-10-29 22:48:47 | 显示全部楼层
By the way, if you re-built(recompiled) 2.4.22 kernel successfully, it would not be necessary to use the old one!
回复

使用道具 举报

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

本版积分规则

GMT+8, 2024-12-5 03:44 , Processed in 0.039535 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

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