- 论坛徽章:
- 0
|
先谢谢大家的帮忙了啊
/*
* Hello world module.
*/
//#include <linux/init.h>
#include <linux/module.h>
#if defined(CONFIG_SMP)
#define __SMP__
#endif
#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/kernel.h>
static __init int init_module(void)
{
printk(KERN_DEBUG "Hello, kernel!\n");
return 0;
}
static __exit void cleanup_module(void)
{
printk(KERN_DEBUG "Good-bye, kernel!\n");
}
这个是Linux程序设计上设备驱动程序开发的代码
我是在虚拟机上安装的CentOS-4.6
我按照书上的编译命令
gcc -D__KERNEL__-DMODULE -DMODVERSIONS -I /user/src/kernels/2.6.9-67.EL-smp-i686/include -Wall -O2 -o hello -c hello.c
但是出现了 <command line>:1:11: warning: ISO C requires whitespace after the macro name
In file included from /usr/include/linux/module.h:10,
from hello.c:6:
/usr/include/linux/config.h:5:2: #error Incorrectly using glibc headers for a kernel module
hello.c:19: error: syntax error before "int"
hello.c: In function `init_module':
hello.c:21: warning: implicit declaration of function `printk'
hello.c:21: error: `KERN_DEBUG' undeclared (first use in this function)
hello.c:21: error: (Each undeclared identifier is reported only once
hello.c:21: error: for each function it appears in.)
hello.c:21: error: syntax error before string constant
hello.c: At top level:
hello.c:25: error: syntax error before "void"
hello.c: In function `cleanup_module':
hello.c:27: error: `KERN_DEBUG' undeclared (first use in this function)
hello.c:27: error: syntax error before string constant
[yangww_cs@localhost driver]$
请问这个问题怎么解决啊?
很着急啊~
已经试了两天了,但是还是这样~
谢谢大家帮忙啊
--------------------------------------------------------------------------------
我的QQ是347073999
大家可以加Q解决~
远程协作~
麻烦了啊~
实在头大啊 |
|