linux内核模块的小问题

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
wang12zhe
帖子: 7
注册时间: 2012-05-25 9:31

linux内核模块的小问题

#1

帖子 wang12zhe » 2012-07-21 19:16

一个hello.c的小程序
#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("GPL");

int hello_init()
{
printk(KERN_WARNING"Hello World %d!\n",year);
return 0;
}

void hello_exit()
{
printk("Hello Exit!\n");
}
module_init(hello_init);
module_exit(hello_exit);




makefile如下:
obj-m : = hello.c
全部是模仿一本书的例子。执行命令:
make -C /usr/src/linux-headers-2.6.38-8 M=$(pwd)modules

出现如下错误:
a123@a123-virtual-machine:~/lx/linux_shebeiqudong$ make -C /usr/src/linux-headers-2.6.38-8 M=$(pwd)modules
make: Entering directory `/usr/src/linux-headers-2.6.38-8'
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.

WARNING: Symbol version dump /usr/src/linux-headers-2.6.38-8/Module.symvers
is missing; modules will have no dependencies and modversions.
scripts/Makefile.build:44: /home/a123/lx/linux_shebeiqudongmodules/Makefile: No such file or directory
make[1]: *** No rule to make target `/home/a123/lx/linux_shebeiqudongmodules/Makefile'. Stop.
make: *** [_module_/home/a123/lx/linux_shebeiqudongmodules] Error 2
make: Leaving directory `/usr/src/linux-headers-2.6.38-8'


求解,不胜感激
mobilefzb
帖子: 224
注册时间: 2010-05-18 22:23

Re: linux内核模块的小问题

#2

帖子 mobilefzb » 2012-07-22 21:04

ERROR: Kernel configuration is invalid.
内核配置无效,
include/generated/autoconf.h or include/config/auto.conf are missing.
上面的文件没有
最好先配置编译一下内核,似乎这个内核的一些文件是在编译过程中生成的。
回复