error in loading the module

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

 



hi,
I have just started to learn Kernel Module Programming from Linux kernel
Module Programming Guide.But I am facing a problem in loading the module
in the kernel.
The code is as follows:

/* hello.c */
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
//#define MODULE
//#define __KERNEL__
static int hello_init(void){
printk(KERN_ALERT "loaded in the kernel\n");
return 0 ;
}

static void hello_exit(void){
printk(KERN_ALERT "successfully unloaded\n");
}
module_init(hello_init);
module_exit(hello_exit);


The source file is hello.c 
The kernel version against which it is compiled is : 2.6.4
The kernel against which it is loaded is : 2.6.4
The command and command line options used for compiling are as follows:

gcc -o2 -c hello.c -Wall -DMODULE -D__KERNEL__
-isystem/lib/modules/`uname -r`/build/include

But when i try to load the module in the kernel it gives the following
error :

No module found in object
insmod : error inserting 'hello.o ' : -1 invalid module format

Am I missing something ?

Thanks in advance.

Regards,
Pankaj


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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