设备驱动程序开发的编译问题
时间:2010-10-12
来源:互联网
先谢谢大家的帮忙了啊
/*
* 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]$
请问这个问题怎么解决啊?
很着急啊~
已经试了两天了,但是还是这样~
谢谢大家帮忙啊
/*
* 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]$
请问这个问题怎么解决啊?
很着急啊~
已经试了两天了,但是还是这样~
谢谢大家帮忙啊
作者: zoe_cs 发布时间: 2010-10-12
我的QQ是347073999
大家可以加Q解决~
远程协作~
麻烦了啊~
实在头大啊
大家可以加Q解决~
远程协作~
麻烦了啊~
实在头大啊
作者: zoe_cs 发布时间: 2010-10-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28