module compilation fails
Hi all,
I tried to compile a simple module on linux and saw a bunch of errors: Module code: 1 #define MODULE 2 #include <linux/module.h> 3 4 int init_module(void) { printk("<1>Hello, world\n"); return 0; } 5 void cleanup_module(void) { printk("<1>Goodbye cruel world\n"); } Errors: "gcc -c hello.c" In file included from /usr/include/linux/sched.h:16, from /usr/include/linux/module.h:9, from hello.c:2: /usr/include/linux/signal.h:2:2: warning: #warning "You should include <signal.h>. 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 hello.c:2: /usr/include/linux/time.h:9: error: redefinition of ‘struct timespec’ /usr/include/linux/time.h:15: error: redefinition of ‘struct timeval’ /usr/include/linux/time.h:20: error: redefinition of ‘struct timezone’ /usr/include/linux/time.h:47: error: redefinition of ‘struct itimerval’ In file included from hello.c:2: /usr/include/linux/module.h:41: error: field ‘attr’ has incomplete type /usr/include/linux/module.h:49: error: field ‘kobj’ has incomplete type I am running Ubuntu 5.10 "Breezy Badger", on kernel 2.6.14.1 Maybe anyone knows where the problem is? Thanx a lot. |
solved
Allready solved the problem. 2.6 kernel seems to have specialised module compilation. You have to write such makefile:
Code:
obj-m := hello.o |
All times are GMT -5. The time now is 11:59 PM. |