paulipe
March 20th, 2006, 08:47 AM
Hi,
I have written my own device driver which only prints one line both during insmod and rmmod (just as an exercise for more complicated things). I have been facing a lot of compilation issues for the same.
First of I had done the following
paulipe@paulipe:~/kernel$ 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
paulipe@paulipe:~/kernel$
After looking around a lot i managed to solve half the problem by downloading sanitized headers http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ and including them in my path.
Now I am stuck at the following place.
paulipe@paulipe:~/kernel$ gcc -I ../temp/linux-libc-headers-2.6.12.0/include/ -c hello.c
In file included from ../temp/linux-libc-headers-2.6.12.0/include/linux/sched.h:16,
from ../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:9,
from hello.c:2:
../temp/linux-libc-headers-2.6.12.0/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 ../temp/linux-libc-headers-2.6.12.0/include/linux/sched.h:79,
from ../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:9,
from hello.c:2:
../temp/linux-libc-headers-2.6.12.0/include/linux/resource.h:2:2: warning: #warning "You should include <sys/resource.h>. This time I will do it for you."
In file included from hello.c:2:
../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:41: error: field ‘attr’ has incomplete type
../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:49: error: field ‘kobj’ has incomplete type
paulipe@paulipe:~/kernel$
Can anybody help me out? I had tried substituting all types of various linux/module.h files to see if any of them worked but to no avail.
This is the hello.c file that I had written (got it of the net).
#define MODULE
#include <linux/module.h>
int init_module (void)
{
printk("Hello Kernel\n");
return 0;
}
void cleanup_module (void)
{
printk("Goodbye Kernel\n");
}
Any help would be appreciated. Thanks
I have written my own device driver which only prints one line both during insmod and rmmod (just as an exercise for more complicated things). I have been facing a lot of compilation issues for the same.
First of I had done the following
paulipe@paulipe:~/kernel$ 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
paulipe@paulipe:~/kernel$
After looking around a lot i managed to solve half the problem by downloading sanitized headers http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ and including them in my path.
Now I am stuck at the following place.
paulipe@paulipe:~/kernel$ gcc -I ../temp/linux-libc-headers-2.6.12.0/include/ -c hello.c
In file included from ../temp/linux-libc-headers-2.6.12.0/include/linux/sched.h:16,
from ../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:9,
from hello.c:2:
../temp/linux-libc-headers-2.6.12.0/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 ../temp/linux-libc-headers-2.6.12.0/include/linux/sched.h:79,
from ../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:9,
from hello.c:2:
../temp/linux-libc-headers-2.6.12.0/include/linux/resource.h:2:2: warning: #warning "You should include <sys/resource.h>. This time I will do it for you."
In file included from hello.c:2:
../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:41: error: field ‘attr’ has incomplete type
../temp/linux-libc-headers-2.6.12.0/include/linux/module.h:49: error: field ‘kobj’ has incomplete type
paulipe@paulipe:~/kernel$
Can anybody help me out? I had tried substituting all types of various linux/module.h files to see if any of them worked but to no avail.
This is the hello.c file that I had written (got it of the net).
#define MODULE
#include <linux/module.h>
int init_module (void)
{
printk("Hello Kernel\n");
return 0;
}
void cleanup_module (void)
{
printk("Goodbye Kernel\n");
}
Any help would be appreciated. Thanks