编译一个内核模块时出现的问题,请高手看一下

jiangli829 2004-08-12 01:33:43
用 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 顶端

...全文
125 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
David2008 2004-08-13
  • 打赏
  • 举报
回复
$gcc -DMODULE -D__KERNEL__ -c hello.c -I /usr/src/linux2.4.20/include
jiangli829 2004-08-12
  • 打赏
  • 举报
回复
我是把 /usr/src/linux/include/linux里的代码全部复制到 /usr/include/linux 里的
并把 /usr/src/linux/include/linux/asm 里的代码复制到 /usr/include/asm 里
沙沙的吹 2004-08-12
  • 打赏
  • 举报
回复
使用-I把引用目录设置到你的linux源代码的include目录看看

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧