免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1390 | 回复: 4
打印 上一主题 下一主题

请教一个简单的驱动程序编译的问题! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-11-23 10:44 |只看该作者 |倒序浏览
test.c 部分代码:
#define __NO_VERSION__
#include <linux/kernel.h>
#include <linux/module.h>
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/version.h>
#include <linux/config.h>
#include <asm/uaccess.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>
unsigned int test_major = 0;
如果包含
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
这几句编译的时候就会出现下面的警告, 去掉上面几句,运行很正常
test.mk源码:
CC=gcc
MODCFLAGS:=-Wall -DMODULE -D__KERNEL__ -DLINUX -I /usr/src/linux-2.4.21-4.EL/include
test.o:test.c
        $(CC) $(MODCFLAGS) -c test.c
////////////////////////
make -f test.mk
gcc  -Wall -DMODULE -D__KERNEL__ -DLINUX -I /usr/src/linux-2.4.21-4.EL/include -c test.c
In file included from /usr/src/linux-2.4.21-4.EL/include/linux/fs.h:19,
                 from /usr/src/linux-2.4.21-4.EL/include/linux/capability.h:17,
                 from /usr/src/linux-2.4.21-4.EL/include/linux/binfmts.h:4,
                 from /usr/src/linux-2.4.21-4.EL/include/linux/sched.h:10,
                 from /usr/src/linux-2.4.21-4.EL/include/asm/uaccess.h:8,
                 from test.c:10:
/usr/src/linux-2.4.21-4.EL/include/linux/dcache.h: In function `dget':
/usr/src/linux-2.4.21-4.EL/include/linux/dcache.h:254: warning: implicit declaration of function `__out_of_line_bug_R8b0fd3c5'
test.c: In function `init_module':
test.c:67: warning: implicit declaration of function `printk_R1b7d4074'
[root@lhcd-server dev_driver]#

请问各位是什么原因啊 ,谢谢了

论坛徽章:
5
2 [报告]
发表于 2005-11-23 11:06 |只看该作者
include <asm/io.h>
include <asm/bug.h>

论坛徽章:
0
3 [报告]
发表于 2005-11-23 14:02 |只看该作者
没有bug.h,只有bugs.h 写错了吧. 加了这2个头文件,错误增多了,是怎么回事啊! 谢谢
#define __NO_VERSION__
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/config.h>
#include <asm/uaccess.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>
#include <asm/io.h>
#include <asm/bugs.h>
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
unsigned int test_major = 0;

[root@lhcd-server dev_driver]# make -f test.mk
gcc  -Wall -DMODULE -D__KERNEL__ -DLINUX -I /usr/src/linux-2.4.21-4.EL/include -c test.c
In file included from test.c:13:
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h: In function `check_bugs':
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:219: `system_utsname' undeclared (first use in this function)
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:219: (Each undeclared identifier is reported only once
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:219: for each function it appears in.)
test.c: In function `init_module':
test.c:67: warning: implicit declaration of function `register_chrdev_Ra758a8b3'
test.c:69: warning: implicit declaration of function `printk_R1b7d4074'
test.c: In function `cleanup_module':
test.c:82: warning: implicit declaration of function `unregister_chrdev_Rc192d491'
test.c: At top level:
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:29: warning: `no_halt' defined but not used
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:37: warning: `mca_pentium' defined but not used
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:45: warning: `no_387' defined but not used
/usr/src/linux-2.4.21-4.EL/include/asm/bugs.h:206: warning: `check_bugs' defined but not used
make: *** [test.o] Error 1
[root@lhcd-server dev_driver]#

论坛徽章:
5
4 [报告]
发表于 2005-11-23 14:24 |只看该作者
你是什么kernel? 自己在include files里找一下你不正常的几个函数看

论坛徽章:
0
5 [报告]
发表于 2005-11-23 16:05 |只看该作者
linux AS3 (2.4.21-4)的内核。
去掉下面几句,我的程序是正常的,可以编译成模块。也写了测试程序,都是正确的,只是我在网上看到有些资料加了下面的语句,我也加了,就出现了上面的错误。我不明白是怎么回事?  谢谢
if CONFIG_MODVERSIONS==1
define MODVERSIONS
include <linux/modversions.h>
endif
#include <asm/bugs.h>
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP