当前位置: 技术问答>linux和unix
刚学LINUX驱动编程,书上的第一个列子就调不过去,请高手指教
来源: 互联网 发布时间:2015-11-06
本文导语: 刚学LINUX驱动编程,书上的第一个列子就调不过去,请高手指教 程序: firstdriver.c #define MODULE #include int init_module(void) { printk("hello worldn"); } void cleanup_module(void) { printk("goodbye curel worldn"); } 编译:gcc -c firstdri...
刚学LINUX驱动编程,书上的第一个列子就调不过去,请高手指教
程序: firstdriver.c
#define MODULE
#include
int init_module(void)
{
printk("hello worldn");
}
void cleanup_module(void)
{
printk("goodbye curel worldn");
}
编译:gcc -c firstdriver.c
输出错误:
In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from firstdriver.c:2:
/usr/include/linux/signal.h:2:2: warning: #warning "You should include . 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 firstdriver.c:2:
/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 firstdriver.c:2:
/usr/include/linux/module.h:41: 错误:字段 ‘attr’ 的类型不完全
/usr/include/linux/module.h:49: 错误:字段 ‘kobj’ 的类型不完全
不知是什么错误
我用的系统是ubuntu 5.1.0
程序: firstdriver.c
#define MODULE
#include
int init_module(void)
{
printk("hello worldn");
}
void cleanup_module(void)
{
printk("goodbye curel worldn");
}
编译:gcc -c firstdriver.c
输出错误:
In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from firstdriver.c:2:
/usr/include/linux/signal.h:2:2: warning: #warning "You should include . 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 firstdriver.c:2:
/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 firstdriver.c:2:
/usr/include/linux/module.h:41: 错误:字段 ‘attr’ 的类型不完全
/usr/include/linux/module.h:49: 错误:字段 ‘kobj’ 的类型不完全
不知是什么错误
我用的系统是ubuntu 5.1.0
|
ubuntu 5.1.0的内核是多少?uname -a看。
|
2.6 内核对内核 Modules 和一般的 Modules 进行了严格的划分,
驱动程序作为内核 Modules 有另外一套的规则。
我有一个很好的文档,你要就留个 email 转给你。
驱动程序作为内核 Modules 有另外一套的规则。
我有一个很好的文档,你要就留个 email 转给你。