Operating System - Linux
1751897 Members
5106 Online
108783 Solutions
New Discussion юеВ

Re: Building linux kernel module/Driver in C code?

 
SOLVED
Go to solution
Vinayak_HPUX
Frequent Advisor

Building linux kernel module/Driver in C code?

I want to compile and run below code I tried lot as

# gcc -C -W -Wall -D__KERNEL__ -DMODULE -isystem /lib/modules/2.6.23.14-115.fc8/build -v /usr/include/linux/version.h -c hello.c

# gcc -C -E -W -Wall -D__KERNEL__ -DMODULE -isystem /lib/modules/2.6.23.14-115.fc8/build -v /usr/include/linux/version.h -c hello.c

# gcc -C -E -W -Wall -D__KERNEL__ -DMODULE -isystem /lib/modules/2.6.23.14-115.fc8/build -v /usr/include/linux/version.h -c hello.c

# gcc -W -Wall -D__KERNEL__ -DMODULE -isystem /lib/modules/2.6.23.14-115.fc8/build -v /usr/include/linux/version.h -c hello.c

# gcc -W -Wall -D__KERNEL__ -DMODULE -isystem /lib/modules/2.6.23.14-115.fc8/build -v /usr/include/linux/version.h -c hello.c

Its not able to find linux/module.h whereas I have installed linux-source code and able to see same file in include/linux/module.h ?


#include
int init_module(void)
{
printk("<1>Hello, world\n");
return 0;
}
void cleanup_module(void)
{
printk("<1>Goodbye cruel world\n");
}


I tried by Creating Makefile with contents:

obj-m := hello.o




===============================then fired below============

# make -C /lib/modules/`uname -r` M=/Project modules
# make -C /lib/modules/`uname -r` M=/Project modules -c hello.c
# make -C /lib/modules/`uname -r` M=/Project modules hello.c
# make -C /lib/modules/`uname -r` M=/Project modules hello.c


But all failed ...................! Need Help
Is Anybody konwing how to compile Kernel C code I have docs to will send to u guys as per ur request for reference????????

My Linux Version :
uname -r
Linux linuxguru.symantec.com 2.6.23.14-115.fc8 #1 SMP Mon Jan 21 14:20:50 EST 2008 i686 i686 i386 GNU/Linux
"Success is matter of law not luck, Make ur own & follow them -Shivkhera[You Can Win] "
2 REPLIES 2
Siert Zijl
Advisor
Solution

Re: Building linux kernel module/Driver in C code?

You might take a look at kerneltrap.org. E.g.: http://kerneltrap.org/node/6955
Linux system administrator
Vinayak_HPUX
Frequent Advisor

Re: Building linux kernel module/Driver in C code?

I got the solutions
"Success is matter of law not luck, Make ur own & follow them -Shivkhera[You Can Win] "