vze4p6c2
December 8th, 2006, 01:24 AM
Hey fellas,
I have been trying to compile and run a simple module from "Linux Device Drivers", and have been unsuccessful lately. I'm a nooby at this point, so I've also looked through simple module codes and they seem to be the same comparing to the one in the book. I use C language. Here the code to be compiled:
#define MODULE
#include <linux/module.h>
int init_module(void) {
printk("<1>The module has started...\n");
return 0;
}
void cleanup_module(void) {
printk("<1>The module has ended...\n");
}
I used a GCC compiler to compile the code:
gcc -c code.c
But I get the following reply from the compiler:
In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from code.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 code.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 code.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
If you guys are good at device drivers, some help resolving this issue would be really apperciated.
Thanks,
Vlad
I have been trying to compile and run a simple module from "Linux Device Drivers", and have been unsuccessful lately. I'm a nooby at this point, so I've also looked through simple module codes and they seem to be the same comparing to the one in the book. I use C language. Here the code to be compiled:
#define MODULE
#include <linux/module.h>
int init_module(void) {
printk("<1>The module has started...\n");
return 0;
}
void cleanup_module(void) {
printk("<1>The module has ended...\n");
}
I used a GCC compiler to compile the code:
gcc -c code.c
But I get the following reply from the compiler:
In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from code.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 code.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 code.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
If you guys are good at device drivers, some help resolving this issue would be really apperciated.
Thanks,
Vlad