LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-28-2008, 03:17 PM   #1
itz2000
Member
 
Registered: Jul 2005
Distribution: Fedora fc4, fc7, Mandrake 10.1, mandriva06, suse 9.1, Slackware 10.2, 11.0, 12.0,1,2 (Current)]
Posts: 732

Rep: Reputation: 30
cannot create kernel objects of kernel modules .c files


Hey guys,
I was trying to create .ko file out of .c file, so I can load it to the kernel as a kernel module... but it doesn't go okay for me :

I got this file in my CWD :
test1.c
which contains my simple LKM (Linux loadable Kernel Module)
and I got this MakeFile
Code:
obj-m += test1.o
but when I try to create the .ko file I get (as root)
Code:
root@me:/home/zuki/programming/kernel_poc# make -C /usr/src/linux-2.6.24.5 SUBDIRS=/home/zuki/programming/kernel_poc/ modules
make: Entering directory `/usr/src/linux-2.6.24.5'
scripts/Makefile.build:41: /home/zuki/programming/kernel_poc/Makefile: No such file or directory
make[1]: *** No rule to make target `/home/zuki/programming/kernel_poc/Makefile'.  Stop.
make: *** [_module_/home/zuki/programming/kernel_poc] Error 2
make: Leaving directory `/usr/src/linux-2.6.24.5'
the test1.ko isn't created in the CWD...

Do you see what I'm doing wrong?

Last edited by itz2000; 05-28-2008 at 03:18 PM.
 
Old 05-28-2008, 03:44 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Quote:
Originally Posted by itz2000 View Post
and I got this MakeFile
Linux kernel Makefiles are very picky. They will not work unless they are exactly named “Makefile” or “Kbuild”. The names “makefile” and “MakeFile” will not work.
 
Old 05-28-2008, 03:47 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
Also, it is recommended to build your modules as an ordinary user (not root).
 
Old 05-29-2008, 07:19 AM   #4
digvijay.gahlot
Member
 
Registered: Mar 2008
Posts: 53

Rep: Reputation: 15
Make a Makefile with following content in you current working directory and the type make on shell.

obj-m := test1.o
KERNELDIR ?= /usr/src/linux-2.6.24.5
PWD := $(shell pwd)
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
 
  


Reply



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
/lib/modules/2.4.33.3/kernel/sound folder is missing after compiling kernel Paulo Góes Slackware - Installation 2 04-15-2007 08:42 PM
my freshly recompiled kernel modules files not gzipped and no sound loaded hottdogg Slackware 12 08-12-2006 01:52 PM
kernel source and .o to .ko objects (fc3) kahn Fedora 2 04-10-2005 05:30 AM
What files control loading of kernel modules? Rimmer Linux - General 1 05-04-2001 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:50 PM.

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
Open Source Consulting | Domain Registration