Hi ,<br>I am a newbie to kernel programming and trying out some simple examples given in a tutorial<br>the program is given below<br><br>#include <linux/module.h> /* Needed by all modules */<br>#include <linux/kernel.h> /* Needed for KERN_INFO */
<br>#include <linux/init.h><br>int init_module(void)<br>{<br> printk(KERN_INFO "Hello world 1.\n");<br> /*<br> * A non 0 return means init_module failed; module can't be loaded.<br> */<br>
return 0;<br>}<br>void cleanup_module(void)<br>{<br> printk(KERN_INFO "Goodbye world 1.\n");<br>}<br><br>============================================<br>I get the following error when i try to compile
<br>I have installed the kernel headers as well<br><br><br>shrikar@shrikar-desktop:~/kernel-programming$ gcc -D__KERNEL__ -DMODULE -DLINUX -Wall -c hello1.c<br>In file included from /usr/include/linux/sched.h:16,<br> from /usr/include/linux/module.h:9,
<br> from hello1.c:1:<br>/usr/include/linux/signal.h:2:2: warning: #warning "You should include <signal.h>. This time I will do it for you."<br>In file included from /usr/include/linux/resource.h:4,
<br> from /usr/include/linux/sched.h:79,<br> from /usr/include/linux/module.h:9,<br> from hello1.c:1:<br>/usr/include/linux/time.h:9: error: redefinition of 'struct timespec'
<br>/usr/include/linux/time.h:15: error: redefinition of 'struct timeval'<br>/usr/include/linux/time.h:20: error: redefinition of 'struct timezone'<br>/usr/include/linux/time.h:47: error: redefinition of 'struct itimerval'
<br>In file included from hello1.c:1:<br>/usr/include/linux/module.h:41: error: field 'attr' has incomplete type<br>/usr/include/linux/module.h:49: error: field 'kobj' has incomplete type<br>hello1.c: In function 'init_module':
<br>hello1.c:6: warning: implicit declaration of function 'printk'<br>hello1.c:6: error: 'KERN_INFO' undeclared (first use in this function)<br>hello1.c:6: error: (Each undeclared identifier is reported only once<br>hello1.c
:6: error: for each function it appears in.)<br>hello1.c:6: error: syntax error before string constant<br>hello1.c: In function 'cleanup_module':<br>hello1.c:14: error: 'KERN_INFO' undeclared (first use in this function)<br>
hello1.c:14: error: syntax error before string constant<br><br><br>Thanks in advance<br>Shrikar<br>