1. Missing Linux kernel header file
To install just the headers in Ubuntu:
sudo apt-get install linux-headers-$ (uname-r) |
To install the entire Linux kernel source in Ubuntu:
sudo apt-get install Linux-source |
Note that your should use the kernel headers, the match the kernel you is running.
2. Kernel Module Compilation process Ubuntu
Source:
**/*source file name is BASIC.C */** #include <linux/init.h> #include <linux/module.h> /*module_license ("Dual BSD/GPL"); * * static int hello_init (void) { PRINTK (Kern_alert "Hello, world\n"); return 0; } static void Hello_exit (void) { PRINTK (Kern_alert "Goodbye, cruel world\n"); } Module_init (Hello_init); Module_exit (Hello_exit); |
Makefile file
/*at first type on ur terminal that $ ( UNAME-R) then u'll get the version. That was using on the UR system */ obj-m + = BASIC.O all: $ (Make)-C $ (Kdir) subdirs=$ (PWD) Modules RM-RF *.o *.ko *.mod.* *.symvers *.order |
Kernel modules run:
$sudo Insmode Basic.ko $DMESG ==> u'll get the output $sudo Rmmod Basic.ko $dmesg |
Reference Links:
Http://stackoverflow.com/questions/16919512/linux-module-h-no-such-file-or-directory
Linux/module.h:no such file or directory kernel module compilation process