分页: 1 / 1

linux 驱动 hello world

发表于 : 2010-01-25 20:19
widon1104
widon@widon-laptop:~/Desktop/drivers/hello$ make
make -C /home/widon/Desktop/drivers/linux-2.6.30.4 M=/home/widon/Desktop/drivers/hello modules
make[1]: 正在进入目录 `/home/widon/Desktop/drivers/linux-2.6.30.4'

ERROR: Kernel configuration is invalid.
include/linux/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.


WARNING: Symbol version dump /home/widon/Desktop/drivers/linux-2.6.30.4/Module.symvers
is missing; modules will have no dependencies and modversions.

CC [M] /home/widon/Desktop/drivers/hello/hello.o
cc1: 错误: include/linux/autoconf.h:没有该文件或目录
In file included from include/linux/prefetch.h:14,
.............................
从 /home/widon/Desktop/drivers/hello/hello.c:2:
/home/widon/Desktop/drivers/linux-2.6.30.4/arch/x86/include/asm/module.h:68:2: 错误: #error unknown processor family
/home/widon/Desktop/drivers/hello/hello.c: 在函数‘__exittest’中:
/home/widon/Desktop/drivers/hello/hello.c:18: 警告: 返回了不兼容的指针类型
make[2]: *** [/home/widon/Desktop/drivers/hello/hello.o] 错误 1
make[1]: *** [_module_/home/widon/Desktop/drivers/hello] 错误 2
make[1]:正在离开目录 `/home/widon/Desktop/drivers/linux-2.6.30.4'
make: *** [default] 错误 2

用这个makefile为什么会有这么多错误啊
widon@widon-laptop:~/Desktop/drivers/hello$ cat Makefile
obj-m := hello.o
KERNELDIR := /home/widon/Desktop/drivers/linux-2.6.30.4
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.cmd *.o *.ko *.mod.c *.symvers *.order
widon@widon-laptop:~/Desktop/drivers/hello$ cat hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");

static int hello_init(void)
{
printk("hello, world\n");
return 0;
}

static int hello_exit(void)
{
printk("Goodbye, cruel world\n");
return 0;
}

module_init(hello_init);
module_exit(hello_exit);

这个makefile可以

widon@widon-laptop:~/Desktop/drivers/hello$ cat Makefile_backup
obj-m := hello.o
KERNELDIR := /lib/modules/$(shell uname -r)/build
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.cmd *.o *.ko *.mod.c *.symvers *.order

Re: linux 驱动 hello world

发表于 : 2010-01-25 21:53
tusooa
make menuconfig