出错: gcc -O6 -Wall -DCONFIG_KERNELD -DMODULE -D__KERNEL__ -DLinux -c hello.c in file included from /usr/include/linux/module.h:20 from hello.c:2 /usr/include/asm/module.h:56:2: #error unknown processor family make: *** [hello.o] error 1
>>> 此贴的回复 >> 没有定义cpu类型?
>>> 此贴的回复 >> 看Linux Device Driver 3/e。
>>> 此贴的回复 >> 我的也出错,也想发表,suse9.1 #include #include #include
static int init_module(void) { printk("Hello,world!\n"); return 0; }
static void cleanup_module(void) { printk("Bay1\n"); }
module_init(init_module); module_exit(cleanup_module);
linux:/software # gcc -c hello.c In file included from /usr/include/linux/sched.h:12, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/jiffies.h:16: error: parse error before "jiffies_64" /usr/include/linux/jiffies.h:20: error: parse error before "get_jiffies_64" In file included from /usr/include/linux/sched.h:21, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/asm/mmu.h:13: error: field `sem' has incomplete type In file included from /usr/include/linux/signal.h:4, from /usr/include/linux/sched.h:25, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/list.h:604:2: warning: #warning "don't include kernel headers in userspace" In file included from /usr/include/asm/siginfo.h:4, from /usr/include/linux/signal.h:7, from /usr/include/linux/sched.h:25, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/asm-generic/siginfo.h:53: error: size of array `_pad' is too large In file included from /usr/include/linux/sched.h:27, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/fs_struct.h:9: error: parse error before "rwlock_t" /usr/include/linux/fs_struct.h:13: error: parse error before '}' token In file included from /usr/include/linux/sched.h:29, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/completion.h:15: error: parse error before "wait_queue_head_t" /usr/include/linux/completion.h: In function `init_completion': /usr/include/linux/completion.h:26: error: dereferencing pointer to incomplete type /usr/include/linux/completion.h:27: error: dereferencing pointer to incomplete type In file included from /usr/include/linux/sched.h:30, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/pid.h: At top level: /usr/include/linux/pid.h:18: error: field `task_list' has incomplete type /usr/include/linux/pid.h:19: error: field `hash_chain' has incomplete type /usr/include/linux/pid.h:24: error: field `pid_chain' has incomplete type In file included from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/sched.h:93: error: parse error before "process_counts" In file included from /usr/include/linux/sched.h:102, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/timer.h:10: error: field `entry' has incomplete type hello.c:6: warning: static declaration for `init_module' follows non-static hello.c:12: warning: static declaration for `cleanup_module' follows non-static hello.c:16: error: parse error before "__attribute_used__" hello.c:16: warning: initialization makes integer from pointer without a cast hello.c:16: warning: data definition has no type or storage class hello.c:17: error: parse error before "__attribute_used__" hello.c:17: error: redefinition of `__attribute_used__' hello.c:16: error: `__attribute_used__' previously defined here hello.c:17: warning: initialization makes integer from pointer without a cast hello.c:17: warning: data definition has no type or storage class
>>> 此贴的回复 >> 2.6的版本用kernel building system 的规则编译。具体方法在ldd3上一清二楚。