LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 06-26-2006, 04:21 PM   #1
abk4523
Member
 
Registered: Jun 2004
Distribution: RH8/Fedora Core 4
Posts: 139

Rep: Reputation: 15
unable to compile module source FC4


What am I missing? I wrote a simple module to test and cannot get it to compile. When I enter make hello I get the following:

make hello
cc hello.c -o hello
hello.c: In function ‘hello_init’:
hello.c:7: error: ‘KERN_ALERT’ undeclared (first use in this function)
hello.c:7: error: (Each undeclared identifier is reported only once
hello.c:7: error: for each function it appears in.)
hello.c:7: error: syntax error before string constant
hello.c: In function ‘hello_exit’:
hello.c:13: error: ‘KERN_ALERT’ undeclared (first use in this function)
hello.c:13: error: syntax error before string constant
make: *** [hello] Error 1

I did some research, and found the following command:

make -C /usr/src/kernels/2.6.16-1.2115_FC4-i686/ M=`pwd` modules hello.c

and got the following results:

make: Entering directory `/usr/src/kernels/2.6.16-1.2115_FC4-i686'
scripts/Makefile.build:15: /root/Makefile: No such file or directory
make[1]: *** No rule to make target `/root/Makefile'. Stop.
make: *** [_module_/root] Error 2
make: Leaving directory `/usr/src/kernels/2.6.16-1.2115_FC4-i686'


I made a Makefile, contents as such:

# if KERNELRELEASE exists, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := hello.c

# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else

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

default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif

I was running this as root. I get these results when using this makefile:

make -C /usr/src/kernels/2.6.16-1.2115_FC4-i686/ M=`pwd` modules hello.c
make: Entering directory `/usr/src/kernels/2.6.16-1.2115_FC4-i686'
scripts/Makefile.build:197: target `/root/hello.c' doesn't match the target pattern
LD /root/built-in.o
Building modules, stage 2.
MODPOST
make: *** No rule to make target `hello.c'. Stop.
make: Leaving directory `/usr/src/kernels/2.6.16-1.2115_FC4-i686'

What did I miss? Thanks in advance.
 
Old 06-28-2006, 02:49 PM   #2
x86processor
Member
 
Registered: Jun 2006
Location: Chennai, India
Distribution: Embdebian, Debian, Fedora Core, Redhat, Slackware, Ubuntu.
Posts: 112

Rep: Reputation: 15
Try my simple Linux device driver examples:

http://www.shakthimaan.com/downloads.html
 
Old 06-29-2006, 08:17 AM   #3
abk4523
Member
 
Registered: Jun 2004
Distribution: RH8/Fedora Core 4
Posts: 139

Original Poster
Rep: Reputation: 15
Thanks for the help Shakthi. I downloaded your examples and extracted the Makefile, but get this error when compiling:

make -C /usr/src/kernels/2.6.17-1.2139_FC4-i686/ M=`` modules hello.c
make: Entering directory `/usr/src/kernels/2.6.17-1.2139_FC4-i686'
CHK include/linux/version.h
make[1]: *** No rule to make target `init/main.o', needed by `init/built-in.o'. Stop.
make: *** [init] Error 2
make: Leaving directory `/usr/src/kernels/2.6.17-1.2139_FC4-i686'

I was logged in as su. Any other guesses?

 
Old 07-06-2007, 04:52 AM   #4
tanalam
LQ Newbie
 
Registered: Dec 2005
Distribution: Redhat, FC
Posts: 28

Rep: Reputation: 15
hie,
Following makefile works for me in fc3
try this out
obj-m += module.o
all:
make -C /lib/modules/`uname -r`/build M=$(PWD) modules
clean:
make -C /lib/modules/`uname -r`/build M=$(PWD) clean

regards
tan...
 
  


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
help: cannot load php5 module, compile from source parv Linux - Networking 2 02-18-2006 12:27 PM
cannot load php5 module in apache 2, compile from source parv Linux - Software 6 02-17-2006 04:29 PM
single module compile in clean source tree henryquinn Linux - Software 3 02-15-2006 03:38 AM
unable to compile source files Hallowedpoint Linux - Newbie 6 11-19-2005 08:02 AM
unable to compile scsi_mod as module in 2.6.9 nbd Linux - General 5 11-28-2004 10:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

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