-   Linux - Kernel (
-   -   loadable kernel module (LKM) issues (

shakthi 07-13-2011 12:44 PM

loadable kernel module (LKM) issues
hi everybody,

I tried to create a new module as given in, hello-1.c.


* hello-1.c - The simplest kernel module.
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
printk(KERN_INFO "Hello world 1.\n");

* A non 0 return means init_module failed; module can't be loaded.
return 0;

void cleanup_module(void)
printk(KERN_INFO "Goodbye world 1.\n");

and then created the Makefile as


obj-m += hello-1.o

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

and then make that... but the following errors are coming:

make -C /lib/modules/ M=/home/rajaram modules
make: *** /lib/modules/ No such file or directory. Stop.
make: *** [all] Error 2

please help me as soon as possible

thanks in advance,

sundialsvcs 07-13-2011 04:59 PM

:study: ...

Well, "start at the beginning, then proceed until you get to the end, then stop." You are, obviously, at the beginning. Does this directory and path exist, or does it not? If not, then what directory should it be? Then, how did the computer come up with this name that it's asking for now?

"Elementary, my dear Watson."

bsat 07-14-2011 02:40 AM

You will need to install the kernel headers to compile kernel modules. The directory that it is searching for will exist only after you have installed the kernel headers.
If you are running ubuntu or debian you can search for linux-headers in the package manager and install the same or run the following from the terminal

sudo apt-get install linux-headers-2.6.38 ( Or some thing similar to that).

Other distros also have similar header packages.

manikumar086 07-26-2011 09:11 AM

Debugging the issue... about "make: *** /lib/modules/ No such file"
Hi Shakthi,
-> Here the error mean is that the Path you had mentioned in your Make file as "/lib/modules/$(shell uname -r)/build" is Incorrect and
-> this can be avoid by directly pointing to your Linux Kernel Dir. of any ver. like 2.6.34(what i had done). So, in this there are the libraries relating to your.


knudfl 07-26-2011 10:02 AM

The Fedora package name is 'kernel-devel'.

# yum install kernel kernel-devel

Then reboot to use the updated kernel and the matching development files.

All times are GMT -5. The time now is 03:54 AM.