|
|

楼主 |
发表于 2006-3-29 23:38:39
|
显示全部楼层
Post by haohao_h
是啊!写驱动要有kernel-source。而且你的是2.4内核的写法,2.6已经有一些变化了。你程序的结构还有编译参数都不对!网上搜一下吧! 我在网上查了一下 重新改动了一下程序还是有错误
程序:
//hello.c
#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>
static int hello_init(void)
{
printk(KERN_ALERT "hello world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "goodbye\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile文件如下:
obj-m := hello.o
编译如下:
make -C ~/linux-2.6.12 M=`pwd` modules
(我下载的是linux-2.6.12-rc2.tar.gz 解压后吧名字改成了linux-2.6.12 我的系统是ubuntu)
错误如下:
make: Entering directory `/home/cooleagle/linux-2.6.12'
Makefile:487: .config: 没有那个文件或目录
WARNING: Symbol version dump /home/cooleagle/linux-2.6.12/Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /home/cooleagle/program/kernel/hello.o
In file included from include/linux/module.h:9,
from /home/cooleagle/program/kernel/hello.c:1:
include/linux/config.h:4:28: error: linux/autoconf.h: 没有那个文件或目录
In file included from include/asm/thread_info.h:17,
from include/linux/thread_info.h:21,
from include/linux/spinlock.h:12,
from include/linux/capability.h:45,
from include/linux/sched.h:7,
from include/linux/module.h:10,
from /home/cooleagle/program/kernel/hello.c:1:
include/asm/processor.h:69: 错误:‘CONFIG_X86_L1_CACHE_SHIFT’ 未声明 (不在函数内)
include/asm/processor.h:69: 错误:要求的对齐边界不是常量
In file included from include/linux/module.h:23,
from /home/cooleagle/program/kernel/hello.c:1:
include/asm/module.h:58:2: error: #error unknown processor family
make[1]: *** [/home/cooleagle/program/kernel/hello.o] 错误 1
make: *** [_module_/home/cooleagle/program/kernel] 错误 2
make: Leaving directory `/home/cooleagle/linux-2.6.12'
请问是什么原因 谢谢 |
|