当前位置: 技术问答>linux和unix
编译一个内核模块时出现的问题,请高手看一下
来源: 互联网 发布时间:2015-07-14
本文导语: 用 cc -c hello.c 编译如下代码 hello.c #define MODULE #define __KERNEL__ #include "linux/kernel.h" #inclu...
用 cc -c hello.c 编译如下代码
hello.c
#define MODULE
#define __KERNEL__
#include "linux/kernel.h"
#include "linux/module.h"
/* pross the CONFIG_MODVERSIONS*/
#ifdef MODVERSIONS
#include "linux/modversions.h"
#endif
/* the init function*/
int init_module()
{
printk(" hello !n");
return 1;
}
/* the distory function*/
int cleanup_module()
{
return 1;
}
出现如下错误提示:
In file included from /usr/include/linux/prefetch.h:13,
from /usr/include/linux/list.h:6,
from /usr/include/linux/module.h:12,
from hello.c:5:
/usr/include/asm/processor.h:65: `CONFIG_X86_L1_CACHE_SHIFT' undeclared here (not in a function)
/usr/include/asm/processor.h:65: requested alignment is not a constant
请高手指点!!!
6,1 顶端
hello.c
#define MODULE
#define __KERNEL__
#include "linux/kernel.h"
#include "linux/module.h"
/* pross the CONFIG_MODVERSIONS*/
#ifdef MODVERSIONS
#include "linux/modversions.h"
#endif
/* the init function*/
int init_module()
{
printk(" hello !n");
return 1;
}
/* the distory function*/
int cleanup_module()
{
return 1;
}
出现如下错误提示:
In file included from /usr/include/linux/prefetch.h:13,
from /usr/include/linux/list.h:6,
from /usr/include/linux/module.h:12,
from hello.c:5:
/usr/include/asm/processor.h:65: `CONFIG_X86_L1_CACHE_SHIFT' undeclared here (not in a function)
/usr/include/asm/processor.h:65: requested alignment is not a constant
请高手指点!!!
6,1 顶端
|
$gcc -DMODULE -D__KERNEL__ -c hello.c -I /usr/src/linux2.4.20/include