Hello:
I have been trying to write the easiest module “Hello World” on SuSE 8.0 (2.4.18-4GB kernel version), but I can’t.
If I use the next code for my hello.c file:
#define MODULE
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("Hello world\n");
return 0;
}
void cleanup_module(void)
{
printk("Bye world\n");
}
When I use the command insmod hello.c, it appears an error saying that it is compiled for the 2.4.17 kernel version, and I am using the 2.4.18-4GB version.
I have tried it with this other code:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int hello_init(void)
{
printk("Hello world\n");
return 0;
}
static void hello_exit(void)
{
printk("Bye world\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
In this case I got an error saying that it can’t identify the kernel version
To compile the hello.c file I’m using the next command: gcc –c hello.c (I don’t know if could be here the problem, of course, I’m a kernel newbie)
Thank you very much...