LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2013, 11:55 PM   #1
shiv garg
LQ Newbie
 
Registered: Sep 2013
Location: Amritsar
Distribution: fedora 19
Posts: 11

Rep: Reputation: Disabled
kernel module makefile problem


sir i was trying to make a makefile
but i was not able to do that
module was simple a hello world program

#include<linux/init.h>
#include<linux/module.h>
MODULE_LISENCE("DUAL bSD/GPL");


static int hello_init(void )
{
printk(KERN_ALERT "HELLO WORLD");
return 0;
}


static int hello_exit(void)
{
printk( KERN_ALERT "thankyou cruel sworld");
}



module_init(hello_init);
module_exi(hello_exit);




its name was demo.c


i made a Makefile

obj-m = foo.o

KVERSION = $(shell uname -r)

all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean


but i ended up on an eror

make -C /lib/modules/3.5.0-23-generic/build M=/home/shiv/Desktop/module modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-23-generic'
make[2]: *** No rule to make target `/home/shiv/Desktop/module/foo.c', needed by `/home/shiv/Desktop/module/foo.o'. Stop.
make[1]: *** [_module_/home/shiv/Desktop/module] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-23-generic'
make: *** [all] Error 2


kindly help
 
Old 10-07-2013, 02:48 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,122

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
As far as I see the name of your test is demo.c you would try:
obj-m = demo.o # instead of foo.o
 
1 members found this post helpful.
Old 10-07-2013, 02:54 AM   #3
shiv garg
LQ Newbie
 
Registered: Sep 2013
Location: Amritsar
Distribution: fedora 19
Posts: 11

Original Poster
Rep: Reputation: Disabled
sir i have tried with demo.o but problem persists
 
Old 10-07-2013, 03:04 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,122

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
please use [code]here comes your code[/code] blocks to keep your formatting and post your new makefile and the complete error message(s)
 
Old 10-07-2013, 06:46 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
The simple module Makefile looks like this
Code:
obj-m    := demo.o

KDIR    := /lib/modules/$(shell uname -r)/build
PWD    := $(shell pwd)

default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
 
Old 10-18-2013, 07:37 AM   #6
shiv garg
LQ Newbie
 
Registered: Sep 2013
Location: Amritsar
Distribution: fedora 19
Posts: 11

Original Poster
Rep: Reputation: Disabled
sir i have succeeded in compiling the make file sucessfully.. and i have loaded the kernal sucessfully ... but pls tell me that where to look for output...
means hello world is not printed on terminal after loading it on the kernal
 
Old 10-18-2013, 10:03 AM   #7
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,122

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
see man syslog about how printk handled
 
1 members found this post helpful.
Old 10-18-2013, 11:34 AM   #8
Ginola
Member
 
Registered: Sep 2012
Location: UK
Distribution: CentOS, RHEL
Posts: 65

Rep: Reputation: Disabled
also, isnt that a typo?

Code:
MODULE_LISENCE("DUAL bSD/GPL");

should be MODULE_LICENSE, right?
 
  


Reply


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
old 2.4 kernel module makefile reuse kannankvs Programming 0 08-18-2009 08:54 PM
problem in linux kernel module copilation using makefile(hello-1.c program) of lkmpg kapilaryan2003 Fedora 2 06-09-2008 06:04 AM
how to edit makefile for kernel module? bhuvanmital Programming 5 02-02-2006 06:06 AM
need help in writing Makefile for module in 2.6 kernel videsh Programming 1 01-19-2006 08:35 AM
module makefile for c++ in kernel 2.6 yuhuahe Linux - Software 0 04-14-2004 07:03 PM


All times are GMT -5. The time now is 10:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration