Help!! How to write an easy module on SuSE 8.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Title: Help!! How to write an easy module on SuSE 8.0



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 cant identify the kernel version

To compile the hello.c file Im using the next command: gcc c hello.c (I dont know if could be here the problem, of course, Im a kernel newbie)

       

Thank you very much...



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux