include/linux/mmzone.h error: linux/bounds.h

 问题:

编译内核驱动模块的时候,提示缺少头文件 mmzone.h 、bounds.h…等

 

include/linux/mmzone.h:18:26: error: linux/bounds.h: No such file or directory
include/linux/mmzone.h:197:5: warning: "MAX_NR_ZONES" is not defined

原因:

bounds.h是在编译内核时生成的,类似于编译产生的.o文件,如果你运行

"make clean" or "make distclean",这个文件就会被清除掉(详情查看内核Makefile)。因此,如果再利用此内核源码编译内核模块,

如果有涉及bounds.h,就会出现找不到该文件的错误。

解决:

独立内核目录之外编译模块时,要确保makefile文件中所定义的内核源代码树已经make过一遍,且没有make  clean。这样就不会清除生成的bound.h头文件,这个文件是生成模块必须的。 

或者"make prepare" 

这样就会重新生成bounds.h,搞定了!

再看看其内容,为:

C++代码
  1. #ifndef __LINUX_BOUNDS_H__  
  2. #define __LINUX_BOUNDS_H__  
  3. /* 
  4.  * DO NOT MODIFY. 
  5.  * 
  6.  * This file was generated by Kbuild 
  7.  * 
  8.  */  
  9.   
  10. #define NR_PAGEFLAGS 19 /* __NR_PAGEFLAGS @ */  
  11. #define MAX_NR_ZONES 3 /* __MAX_NR_ZONES @ */  
  12.   
  13. #endif  
点赞 (0)

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Captcha Code