Driver porting: hello world
Driver porting: hello world
Posted Feb 11, 2006 12:26 UTC (Sat) by vikasvasud (guest, #35870)Parent article: Driver porting: hello world
Hi
I am new to kernel programming. I am using Fedora Core. kernel version 2.6.5-1.358.
My code is
>>>>>
#include<linux/module.h>
#include<linux/kernel.h>
int init_module()
{printk("welcome to the world of kernel programming");
return 0;
}
void init_module()
{printk("removing from kernel space");
}
MODULE_LICENCE("GPL");
>>>>>>
i have named this source file as hello.c
Now the problem is i dont know how to insert this module in the kernel space. I have tried gcc -c hello.c to generate hello.o. And then i tried insmod hello.o but to my luck no go . i know this method works with kernel 2.4. But with 2.6 i am not much sure
So i tried modprobe hello.o and i got the message module format not supported.
Finally i tried gcc -I/usr/src/linux-2.6.5-1.358/include -c hello.o
But first it gave me some linker error
then i tried gcc -c hello.0 hello.c
and i got the following errors.
************
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
/tmp/cckOZLS5.o(.text+0xf): In function `init_module':
: undefined reference to `printk'
/tmp/cckOZLS5.o(.text+0x2c): In function `cleanup_module':
: undefined reference to `printk'
collect2: ld returned 1 exit status
************
I really dont know what i am doing wrong please suggest me as it is really very important for me.
Thank you in advance
Regards
Vikas Vasudev
