make自己写的模块时出错,求助!

C、C++和Java语言
回复
zariphix
帖子: 7
注册时间: 2006-02-28 19:08
送出感谢: 0
接收感谢: 0

make自己写的模块时出错,求助!

#1

帖子 zariphix » 2006-03-10 13:19

我写了一个名为zariphix_modules_001.c的模块,代码如下:
1 #include<linux/version.h>
2 #include<linux/config.h>
3
4 #if CONFIG_MODVERSIONS==1
5 #define MODVERSIONS
6 #include <linux/modversions.h>
7 #endif
8
9 #include<linux/module.h>
10 #include<linux/kernel.h>
11
12 int init_module(){
13 printk("Hello World!\n");
14 return 0;
15 }
16
17 void cleanup_module(){
18 printk("Bye-bye!\n");
19 }
还写了一个Makefile,内容如下:
1 CC=gcc
2 MODFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
3
4 zariphix_modules_001.o: zariphix_modules_001.c /usr/include/linux/version.h
5 $(CC) $(MODFLAGS) -c zariphix_modules_001.c
在make的时候提示出错:


gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -c zariphix_modules_001.c
In file included from zariphix_modules_001.c:2:
/usr/include/linux/config.h:1:2: error: #error "Compilation aborted. Please read the FAQ for linux-libc-headers package."
/usr/include/linux/config.h:2:2: error: #error "(can be found at http://ep09.pld-linux.org/~mmazur/linux ... aders/doc/)"
In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from zariphix_modules_001.c:9:
/usr/include/linux/signal.h:2:2: warning: #warning "You should include <signal.h>. This time I will do it for you."
In file included from /usr/include/linux/resource.h:4,
from /usr/include/linux/sched.h:79,
from /usr/include/linux/module.h:9,
from zariphix_modules_001.c:9:
/usr/include/linux/time.h:9: 错误:‘struct timespec’ 重定义
/usr/include/linux/time.h:15: 错误:‘struct timeval’ 重定义
/usr/include/linux/time.h:20: 错误:‘struct timezone’ 重定义
/usr/include/linux/time.h:47: 错误:‘struct itimerval’ 重定义
In file included from zariphix_modules_001.c:9:
/usr/include/linux/module.h:41: 错误:字段 ‘attr’ 的类型不完全
/usr/include/linux/module.h:49: 错误:字段 ‘kobj’ 的类型不完全
zariphix_modules_001.c: 在函数 ‘init_module’ 中:
zariphix_modules_001.c:13: 警告:隐式声明函数 ‘printk’
make: *** [zariphix_modules_001.o] 错误 1


请问这是怎么回事,应该怎么解决呢?
回复

回到 “C/C++/Java”