LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   loadable kernel module (LKM) issues (http://www.linuxquestions.org/questions/linux-kernel-70/loadable-kernel-module-lkm-issues-891515/)

shakthi 07-13-2011 11:44 AM

loadable kernel module (LKM) issues
 
hi everybody,

I tried to create a new module as given in http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html, hello-1.c.

Code:

/*
* 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

Code:

obj-m += hello-1.o

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

clean:
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/2.6.38.8-35.fc15.i686/build M=/home/rajaram modules
make: *** /lib/modules/2.6.38.8-35.fc15.i686/build: No such file or directory. Stop.
make: *** [all] Error 2


please help me as soon as possible

thanks in advance,
shakthi

sundialsvcs 07-13-2011 03: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 01: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 08:11 AM

Debugging the issue... about "make: *** /lib/modules/2.6.38.8-35.fc15.i686/build: 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.

Thanks
Mani

knudfl 07-26-2011 09: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 12:56 PM.