编译模块的时候出现的莫名奇怪的错误

本文记录了一次在Linux 2.6.30内核环境下编译自定义模块(globalmem)时遇到的编译错误及警告信息,并提供了解决方案。主要问题包括找不到文件linux/bounds.h、未定义宏'MAX_NR_ZONES'和'NR_PAGEFLAGS'以及格式字符串与参数类型不匹配等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@qljt globalmem]# make -C /linux_kernel/linux-2.6.30/ M=/linux_drivers/06/globalmem/ modules
make: Entering directory `/linux_kernel/linux-2.6.30'
  CC [M]  /linux_drivers/06/globalmem/globalmem.o
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /linux_drivers/06/globalmem/globalmem.c:7:
include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:256:5: warning: "MAX_NR_ZONES" is not defined
In file included from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from /linux_drivers/06/globalmem/globalmem.c:7:
include/linux/mmzone.h:290: error: 'MAX_NR_ZONES' undeclared here (not in a function)
In file included from /linux_drivers/06/globalmem/globalmem.c:11:
include/linux/mm.h:446:63: warning: "NR_PAGEFLAGS" is not defined
include/linux/mm.h:494:62: warning: "NR_PAGEFLAGS" is not defined
/linux_drivers/06/globalmem/globalmem.c: In function 'globalmem_read':
/linux_drivers/06/globalmem/globalmem.c:89: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
/linux_drivers/06/globalmem/globalmem.c: In function 'globalmem_write':
/linux_drivers/06/globalmem/globalmem.c:118: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
make[1]: *** [/linux_drivers/06/globalmem/globalmem.o] Error 1
make: *** [_module_/linux_drivers/06/globalmem] Error 2
make: Leaving directory `/linux_kernel/linux-2.6.30

 

解决的办法:

到你内核的根目录下执行

 

#make zImage  或

#make prepare

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值