+ -
当前位置:首页 → 问答吧 → Linux Device Driver学习平台问题

Linux Device Driver学习平台问题

时间:2010-08-20

来源:互联网

帮个忙看一下这是些什么错误呀,我是初学者,解决不了:
jinjun8505@ubuntu:~$ vi tester.c
jinjun8505@ubuntu:~$ gcc -O2 -DMODULE -D__KERNEL__ -c tester.c
tester.c:1:2: error: invalid preprocessing directive #define_NO_VERSON_
tester.c:2:26: error: linux/modules.h: 没有那个文件或目录
tester.c:5: error: ‘UTS_RELEASE’ undeclared here (not in a function)
tester.c:8: error: expected declaration specifiers or ‘...’ before ‘off_t’
tester.c:8: warning: ‘struct file’ declared inside parameter list
tester.c:8: warning: its scope is only this definition or declaration, which is probably not what you want
tester.c:8: warning: ‘struct inode’ declared inside parameter list
tester.c:9: warning: ‘struct file’ declared inside parameter list
tester.c:9: warning: ‘struct inode’ declared inside parameter list
tester.c:10: error: expected declaration specifiers or ‘...’ before ‘off_t’
tester.c:10: warning: ‘struct file’ declared inside parameter list
tester.c:10: warning: ‘struct inode’ declared inside parameter list
tester.c:11: warning: ‘struct direct’ declared inside parameter list
tester.c:11: warning: ‘struct file’ declared inside parameter list
tester.c:11: warning: ‘struct inode’ declared inside parameter list
tester.c:12: error: expected declaration specifiers or ‘...’ before ‘select_table’
tester.c:12: warning: ‘struct file’ declared inside parameter list
tester.c:12: warning: ‘struct inode’ declared inside parameter list
tester.c:13: warning: ‘struct file’ declared inside parameter list
tester.c:13: warning: ‘struct inode’ declared inside parameter list
tester.c:14: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
tester.c:15: error: expected ‘;’ before ‘int’
In file included from /usr/include/asm-generic/types.h:7,
from /usr/include/asm/types.h:6,
from /usr/include/linux/types.h:4,
from tester.c:23:
/usr/include/asm-generic/int-ll64.h:19: error: two or more data types in declaration specifiers
/usr/include/asm-generic/int-ll64.h:19: error: two or more data types in declaration specifiers
tester.c:25:21: error: linux/mm.h: 没有那个文件或目录
tester.c:27:24: error: asm/segment.h: 没有那个文件或目录
tester.c:30: warning: ‘struct file’ declared inside parameter list
tester.c:30: warning: ‘struct inode’ declared inside parameter list
tester.c: In function ‘read_test’:
tester.c:33: error: ‘VERIFY_WRITE’ undeclared (first use in this function)
tester.c:33: error: (Each undeclared identifier is reported only once
tester.c:33: error: for each function it appears in.)
tester.c: At top level:
tester.c:42: warning: ‘struct file’ declared inside parameter list
tester.c:42: warning: ‘struct inode’ declared inside parameter list
tester.c:47: warning: ‘struct file’ declared inside parameter list
tester.c:47: warning: ‘struct inode’ declared inside parameter list
tester.c: In function ‘open_tibet’:
tester.c:49: error: ‘MOD_INC_USE_COUNT’ undeclared (first use in this function)
tester.c: At top level:
tester.c:53: warning: ‘struct file’ declared inside parameter list
tester.c:53: warning: ‘struct inode’ declared inside parameter list
tester.c: In function ‘release_tibet’:
tester.c:55: error: ‘MOD_DEC_USE_COUNT’ undeclared (first use in this function)
tester.c: At top level:
tester.c:58: error: variable ‘test_fops’ has initializer but incomplete type
tester.c:59: warning: excess elements in struct initializer
tester.c:59: warning: (near initialization for ‘test_fops’)
tester.c:60: warning: excess elements in struct initializer
tester.c:60: warning: (near initialization for ‘test_fops’)
tester.c:61: error: ‘write_test’ undeclared here (not in a function)
tester.c:61: warning: excess elements in struct initializer
tester.c:61: warning: (near initialization for ‘test_fops’)
tester.c:62: warning: excess elements in struct initializer
tester.c:62: warning: (near initialization for ‘test_fops’)
tester.c:63: warning: excess elements in struct initializer
tester.c:63: warning: (near initialization for ‘test_fops’)
tester.c:64: warning: excess elements in struct initializer
tester.c:64: warning: (near initialization for ‘test_fops’)
tester.c:65: warning: excess elements in struct initializer
tester.c:65: warning: (near initialization for ‘test_fops’)
tester.c:66: error: ‘open_test’ undeclared here (not in a function)
tester.c:66: warning: excess elements in struct initializer
tester.c:66: warning: (near initialization for ‘test_fops’)
tester.c:67: error: ‘release_test’ undeclared here (not in a function)
tester.c:67: warning: excess elements in struct initializer
tester.c:67: warning: (near initialization for ‘test_fops’)
tester.c:67: warning: excess elements in struct initializer
tester.c:67: warning: (near initialization for ‘test_fops’)
tester.c:68: warning: excess elements in struct initializer
tester.c:68: warning: (near initialization for ‘test_fops’)
tester.c: In function ‘init_module’:
tester.c:78: error: ‘KERN_INFO’ undeclared (first use in this function)
tester.c:78: error: expected ‘)’ before string constant

作者: jinjun8505   发布时间: 2010-08-20

你是跟谁学的这编译方法,扁他。


内核模块不是这样编译的,好歹你也要带上内核路径把,不然它去哪里找头文件啊。

作者: linjiework   发布时间: 2010-08-20