LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 07-13-2011, 12:44 PM   #1
shakthi
LQ Newbie
 
Registered: May 2011
Posts: 11

Rep: Reputation: 0
Unhappy 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
 
Old 07-13-2011, 04:59 PM   #2
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
...

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."
 
Old 07-14-2011, 02:40 AM   #3
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
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.
 
Old 07-26-2011, 09:11 AM   #4
manikumar086
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Rep: Reputation: Disabled
Thumbs up 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
 
Old 07-26-2011, 10:02 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,286

Rep: Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664
The Fedora package name is 'kernel-devel'.

# yum install kernel kernel-devel

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


Reply

Tags
kernel module, make, makefile


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Load Kernel Loadable MOdule... mohit.saha Linux - Software 3 04-18-2008 11:00 AM
I want add my own system call using LKM (loadable kernel module)... raga4223688 Linux - Software 1 03-07-2007 08:21 AM
how to insert a loadable module into the kernel.? moog Linux - Newbie 2 01-08-2007 09:37 AM
Help, loadable kernel module . ERBRMN Linux - General 3 10-13-2006 08:34 AM
loadable kernel module brajesh Linux - General 2 01-17-2003 01:54 AM


All times are GMT -5. The time now is 05:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration