LinuxQuestions.org
Review your favorite Linux distribution.
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 03-16-2006, 08:40 AM   #1
DrowningFish
LQ Newbie
 
Registered: Aug 2005
Posts: 12

Rep: Reputation: 0
compiling modules in kernel 2.6


I write a simple test file, mymodule.c. Makefile as below
########################
obj-m := mymodule.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
##########################
[root@localhost hello]# make
make -C /lib/modules/2.6.8.1-12mdk/build M=/home/yipiao/programing linux/code/chapter18/hello modules
make[1]: Entering directory `/usr/src/linux-2.6.8.1-12mdk'
make[1]: *** No rule to make target `linux/code/chapter18/hello'. Stop.
make[1]: Leaving directory `/usr/src/linux-2.6.8.1-12mdk'
make: *** [all] Error 2

what is the problem?
 
Old 03-16-2006, 10:30 PM   #2
paragn
Member
 
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259

Rep: Reputation: 30
hi,
why r u using modules last word in make command??
try
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) in makefile
 
Old 03-17-2006, 09:35 PM   #3
rajtendulkar
Member
 
Registered: Mar 2006
Posts: 34

Rep: Reputation: 15
The Makefile that works for me is...

1 ifneq ($(KERNELRELEASE),)
2 obj-m :=driver.o
3 else
4 KERNELDIR ?= /lib/modules/$(shell uname -r)/build
5 PWD:=$(shell pwd)
6 default:
7 $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
8 endif
9
10 clean:
11 rm -rf *.ko
12 rm -rf *.o
13 rm -rf *.mod.c


P.S. I am using Kernel Version 2.6
 
Old 03-18-2006, 12:24 AM   #4
paragn
Member
 
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259

Rep: Reputation: 30
hi,
yes its working Makefile without linenos
 
Old 03-18-2006, 05:03 AM   #5
DrowningFish
LQ Newbie
 
Registered: Aug 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Smile

i have settled the problem, the Makefile is all right if the directory does not include space. the space in the directory "programing linux" makes the mess.i changed the directory name, then it is working now...

thank you all
 
  


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
Compiling kernel modules NNP Programming 4 12-18-2005 02:08 PM
compiling kernel modules axr0284 Programming 2 11-26-2005 03:08 PM
Modules in Kernel Compiling SlackwareInAZ Slackware 1 07-29-2005 05:10 AM
Compiling Modules for 2.6.6 kernel! Bigg Mike Linux - Newbie 9 06-09-2004 09:04 PM
Compiling kernel modules? jrjarrett Linux - Software 0 09-09-2003 10:24 AM

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

All times are GMT -5. The time now is 05:53 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