QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3153|回复: 2

动态加载内核模块的问题

[复制链接]
发表于 2007-9-18 14:40:13 | 显示全部楼层 |阅读模式
这几天在学习动态加载内核模块,     写了一个最简单的“helloworld“模块, 编译的时候出了很多问题, 我用的是FC5, 2.6.15内核, gcc版本4.1.0, 编译环境与我正在使用的内核编译环境相同, 源码中包含的头文件是/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h。
执行gcc -c helloworld.c, 错误提示如下:

[root@localhost helloworld]# gcc -c helloworld.c
In file included from /usr/include/linux/sched.h:13,
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10,
                 from helloworld.c:2:
/usr/include/linux/times.h:7: 错误:expected specifier-qualifier-list before ‘clock_t’
In file included from /usr/include/linux/sched.h:14,
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10,
                 from helloworld.c:2:
/usr/include/linux/timex.h:148: 错误:字段 ‘time’ 的类型不完全
In file included from /usr/include/linux/signal.h:4,
                 from /usr/include/linux/sched.h:25,
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10,
                 from helloworld.c:2:
/usr/include/asm/signal.h:107: 错误:expected specifier-qualifier-list before ‘sigset_t’
In file included from /usr/include/linux/signal.h:5,
                 from /usr/include/linux/sched.h:25,
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10,
                 from helloworld.c:2:
/usr/include/asm/siginfo.h:48: 错误:expected specifier-qualifier-list before ‘clock_t’
In file included from /usr/include/linux/sched.h:65,
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10,
                 from helloworld.c:2:
/usr/include/linux/time.h:10: 错误:expected specifier-qualifier-list before ‘time_t’
/usr/include/linux/time.h:18: 错误:expected specifier-qualifier-list before ‘time_t’
In file included from /usr/include/linux/sched.h:69,
                 from /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:10,
                 from helloworld.c:2:
/usr/include/asm/processor.h:73: 错误:数组元素的类型不完全
在包含自 helloworld.c:2 的文件中:
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:15:25: 错误:linux/cache.h:没有那个文件或目录
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:16:24: 错误:linux/kmod.h:没有那个文件或目录
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:18:29: 错误:linux/stringify.h:没有那个文件或目录
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:19:27: 错误:linux/kobject.h:没有那个文件或目录
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:20:31: 错误:linux/moduleparam.h:没有那个文件或目录
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:21:23: 错误:asm/local.h:没有那个文件或目录
在包含自 /usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:23 的文件中,
                 从 helloworld.c:2:
/usr/include/asm/module.h:4:2: 警告:#warning Using kernel headers in userspace!
In file included from helloworld.c:2:
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:50: 错误:字段 ‘attr’ 的类型不完全
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:61: 错误:字段 ‘kobj’ 的类型不完全
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:573: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_register’
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:575: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_unregister’
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:576: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_get_request’
/usr/src/redhat/BUILD/kernel-2.6.15/linux-2.6.15.i686/include/linux/module.h:578: 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘inter_module_put’
哪位大虾帮我分析一下什么地方出了问题?  谢谢!!

[ 本帖最后由 SeanYu 于 2007-9-18 20:44 编辑 ]
发表于 2007-11-15 15:26:20 | 显示全部楼层
内核模块不是这么编译的,建议你去看看linux device driver 3rd
回复

使用道具 举报

发表于 2007-11-16 01:23:15 | 显示全部楼层
太搞了

有些东西还是要看书的
回复

使用道具 举报

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

本版积分规则

GMT+8, 2024-3-29 22:19 , Processed in 0.338968 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

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