Results 1 to 3 of 3
I am trying to compile kernel module in Fedora Core 5.
After installing the kernel source,I tried hello module. But it reports errors.
hello.c
/*
* $Id: hello.c,v 1.5 2004/10/26 ...
- 07-30-2006 #1Just Joined!
- Join Date
- Jul 2006
- Posts
- 2
How to compile kernel module in Fedore core 5?
I am trying to compile kernel module in Fedora Core 5.
After installing the kernel source,I tried hello module. But it reports errors.
hello.c
/*
* $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $
*/
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk("Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk("Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
////////////// 1, Using gcc compile hello.c directly
Below is the results:
[root@localhost kerneldriver]# gcc -c hello.c
[root@localhost kerneldriver]# insmod ./hello.o
insmod: error inserting './hello.o': -1 Invalid module format
////////////// 2, Using Makefile
Then I followed Linux device driver 3,the Makefile :
The Makefile :
#CC=gcc
#MODCFLAGS : = -Wall -DMODULE -D__KERNEL__ -DLINUX
#hello.o: hello.c /usr/include/linux/version.h
#$(CC) $(MODCFLAGS) -c hello.c
obj-m := hello.o
I compiled it like this:
make -C /usr/src/kernels/2.6.15-1.2054_FC5-i686 M=`pwd` modules
It reports many errors.
Any one provide me some hints? Thanks in advance!
- 07-30-2006 #2
Read this link:
http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html
And I thinkd that you should add a <linux/kernel.h> include
Regards
- 07-31-2006 #3Just Joined!
- Join Date
- Jul 2006
- Posts
- 2
I followed the guide of tldp.org.It failed again.
There are errors in the source codes of 2.6.15-1.2054_FC5-i686.
But the codes are provided by FC5..


Reply With Quote
