免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2688 | 回复: 3
打印 上一主题 下一主题

请教gcc编译问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-23 23:48 |只看该作者 |倒序浏览
[root@localhost lulu_linux]# make
gcc   -D_KERNEL_ -D_MODULE -I  -O2 -Wall -O -c lulu.c -o lulu.o
In file included from /usr/include/linux/sched.h:13,
                 from lulu.c:5:
/usr/include/linux/times.h:7: error: syntax error before "clock_t"
/usr/include/linux/times.h:9: error: syntax error before "tms_cutime"
/usr/include/linux/times.h:10: error: syntax error before "tms_cstime"
In file included from /usr/include/linux/sched.h:14,
                 from lulu.c:5:
/usr/include/linux/timex.h:148: error: field `time' has incomplete type
In file included from /usr/include/linux/signal.h:4,
                 from /usr/include/linux/sched.h:25,
                 from lulu.c:5:
/usr/include/asm/signal.h:107: error: syntax error before "sigset_t"
/usr/include/asm/signal.h:110: error: syntax error before '}' token
In file included from /usr/include/linux/signal.h:5,
                 from /usr/include/linux/sched.h:25,
                 from lulu.c:5:
/usr/include/asm/siginfo.h:26: error: syntax error before "pid_t"
/usr/include/asm/siginfo.h:38: error: syntax error before "pid_t"
/usr/include/asm/siginfo.h:41: error: syntax error before '}' token
/usr/include/asm/siginfo.h:45: error: syntax error before "pid_t"
/usr/include/asm/siginfo.h:48: error: syntax error before "_utime"
/usr/include/asm/siginfo.h:49: error: syntax error before "_stime"
/usr/include/asm/siginfo.h:62: error: syntax error before '}' token
/usr/include/asm/siginfo.h:63: error: syntax error before '}' token
In file included from /usr/include/linux/sched.h:65,
                 from lulu.c:5:
/usr/include/linux/time.h:10: error: syntax error before "time_t"
/usr/include/linux/time.h:12: error: syntax error before '}' token
/usr/include/linux/time.h:18: error: syntax error before "time_t"
/usr/include/linux/time.h:44: error: field `it_interval' has incomplete type
/usr/include/linux/time.h:45: error: field `it_value' has incomplete type
/usr/include/linux/time.h:49: error: field `it_interval' has incomplete type
/usr/include/linux/time.h:50: error: field `it_value' has incomplete type
In file included from /usr/include/linux/sched.h:67,
                 from lulu.c:5:
/usr/include/linux/resource.h:22: error: field `ru_utime' has incomplete type
/usr/include/linux/resource.h:23: error: field `ru_stime' has incomplete type
lulu.c:10: warning: "struct file" declared inside parameter list
lulu.c:10: warning: its scope is only this definition or declaration, which is probably not what you want
lulu.c:10: warning: "struct inode" declared inside parameter list
lulu.c:11: warning: "struct file" declared inside parameter list
lulu.c:11: warning: "struct inode" declared inside parameter list
lulu.c:12: error: syntax error before "lulu_read"
lulu.c:12: error: syntax error before "loff_t"
lulu.c:12: warning: type defaults to `int' in declaration of `lulu_read'
lulu.c:12: warning: data definition has no type or storage class
lulu.c:13: warning: "struct file" declared inside parameter list
lulu.c:13: warning: "struct inode" declared inside parameter list
lulu.c:19: error: variable `lulu_fops' has initializer but incomplete type
lulu.c:20:28: token "=" is not valid in preprocessor expressions
lulu.c:23: error: unknown field `llseek' specified in initializer
lulu.c:23: warning: excess elements in struct initializer
lulu.c:23: warning: (near initialization for `lulu_fops')
lulu.c:24: error: unknown field `read' specified in initializer
lulu.c:24: warning: excess elements in struct initializer
lulu.c:24: warning: (near initialization for `lulu_fops')
lulu.c:25: error: unknown field `write' specified in initializer
lulu.c:25: error: `lulu_write' undeclared here (not in a function)
lulu.c:25: warning: excess elements in struct initializer
lulu.c:25: warning: (near initialization for `lulu_fops')
lulu.c:26: error: unknown field `ioctl' specified in initializer
lulu.c:26: warning: excess elements in struct initializer
lulu.c:26: warning: (near initialization for `lulu_fops')
lulu.c:27: error: unknown field `open' specified in initializer
lulu.c:27: warning: excess elements in struct initializer
lulu.c:27: warning: (near initialization for `lulu_fops')
lulu.c:28: error: unknown field `release' specified in initializer
lulu.c:28: error: `lulu_release' undeclared here (not in a function)
lulu.c:28: warning: excess elements in struct initializer
lulu.c:28: warning: (near initialization for `lulu_fops')
lulu.c: In function `lulu_init':
lulu.c:35: warning: implicit declaration of function `register_chrdev'
lulu.c:37: warning: implicit declaration of function `printk'
lulu.c:37: error: `KERN_CRIT' undeclared (first use in this function)
lulu.c:37: error: (Each undeclared identifier is reported only once
lulu.c:37: error: for each function it appears in.)
lulu.c:37: error: syntax error before string constant
lulu.c:47:2: invalid preprocessing directive #indef
lulu.c: At top level:
lulu.c:49: error: syntax error before string constant
lulu.c:49: warning: type defaults to `int' in declaration of `MODULE_DESCRIPION'lulu.c:49: warning: data definition has no type or storage class
lulu.c:51:49: macro "MODULE_PARM" requires 2 arguments, but only 1 given
lulu.c:51: warning: type defaults to `int' in declaration of `MODULE_PARM'
lulu.c:51: warning: data definition has no type or storage class
lulu.c: In function `cleanuo_module':
lulu.c:58: warning: implicit declaration of function `lulu_cleanup'
lulu.c: At top level:
lulu.c:19: error: storage size of `lulu_fops' isn't known
lulu.c:10: warning: 'lulu_open' declared `static' but never defined
lulu.c:11: warning: 'lulu_close' declared `static' but never defined
lulu.c:13: warning: 'lulu_ioctl' declared `static' but never defined
lulu.c:14: warning: 'lulu_clean' declared `static' but never defined
make: *** [lulu.o] 错误 1

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
2 [报告]
发表于 2007-04-23 23:56 |只看该作者
原帖由 luylg622 于 2007-4-23 23:48 发表于 1楼  
# make
gcc   -D_KERNEL_ -D_MODULE -I  -O2 -Wall -O -c lulu.c -o lulu.o
In file included from /usr/include/linux/sched.h:13,
                 from lulu.c:5:
/usr/include/linux/times.h:7: error ...

在编译内核模块?这个 lulu.c 是楼主自己写的吧?能写内核模块这些报错应该很轻松就可以搞定。例如第一个报错
/usr/include/linux/times.h:7: error: syntax error before "clock_t"

往往就是因为没有包含恰当的头文件,导致 clock_t 的定义找不到。

论坛徽章:
0
3 [报告]
发表于 2007-04-25 13:16 |只看该作者

回复 #2 MMMIX 的帖子

是想编个LED字符驱动的模块,编译就报那些错误,应该是头文件INCLUDE有问题把。
现在头都是大的。。
可以告诉我你的联系方式吗
我QQ:76199220

论坛徽章:
95
程序设计版块每日发帖之星
日期:2015-09-05 06:20:00程序设计版块每日发帖之星
日期:2015-09-17 06:20:00程序设计版块每日发帖之星
日期:2015-09-18 06:20:002015亚冠之阿尔艾因
日期:2015-09-18 10:35:08月度论坛发贴之星
日期:2015-09-30 22:25:002015亚冠之阿尔沙巴布
日期:2015-10-03 08:57:39程序设计版块每日发帖之星
日期:2015-10-05 06:20:00每日论坛发贴之星
日期:2015-10-05 06:20:002015年亚冠纪念徽章
日期:2015-10-06 10:06:482015亚冠之塔什干棉农
日期:2015-10-19 19:43:35程序设计版块每日发帖之星
日期:2015-10-21 06:20:00每日论坛发贴之星
日期:2015-09-14 06:20:00
4 [报告]
发表于 2007-04-25 14:02 |只看该作者
原帖由 luylg622 于 2007-4-25 13:16 发表于 3楼  
是想编个LED字符驱动的模块,编译就报那些错误,应该是头文件INCLUDE有问题把。
现在头都是大的。。
可以告诉我你的联系方式吗
我QQ:76199220

有问题直接在论坛上发贴吧,这那么多高手在。

在帖子中把问题描述清楚,然后起个好点的标题就可以了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP