writing a simple module trying to learn about writing device drivers...but i cant seem to get my code to compile properly
hello_module.c:
Code:
#include <linux/module.h>
#if defined(CONFIG_SMP)
#define __SMP__
#endif
#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/kernel.h>
int init_module(void)
{
printk("<7>Hello kernel!\n");
return 0;
}
void cleanup_module(void)
{
printk("<7>Good-bye kernel!\n");
}
however when i try to compile and insert it i get this:
[root@localhost root]# gcc -D __KERNEL -D MODULE -O2 -W -Wall -c hello_module.c
hello_module.c: In function `init_module':
hello_module.c:16: warning: implicit declaration of function `printk'
[root@localhost root]# insmod hello_module.o
insmod: error inserting 'hello_module.o': -1 Invalid module format
if anyone could point me in the right direction it'd be greatly appreciated
23,1 All