LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 05-02-2008, 05:40 AM   #1
vin2008_linux
LQ Newbie
 
Registered: May 2008
Posts: 3

Rep: Reputation: 0
Kernel Programming vin2008_linux


I am not able to compile c code
gcc is not getting path of module.h and kernel.h

#include <module.h> /* Needed by all modules */
#include <kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
=========================
[root@linuxguru.symantec.com][ /usr/src ]gcc -o hello-1.0 hello-1.c
hello-1.c:1:54: error: module.h: No such file or directory
hello-1.c:2:53: error: kernel.h: No such file or directory
hello-1.c: In function ‘init_module’:
hello-1.c:6: error: ‘KERN_INFO’ undeclared (first use in this function)
hello-1.c:6: error: (Each undeclared identifier is reported only once
hello-1.c:6: error: for each function it appears in.)
hello-1.c:6: error: expected ‘)’ before string constant
hello-1.c: In function ‘cleanup_module’:
hello-1.c:14: error: ‘KERN_INFO’ undeclared (first use in this function)
hello-1.c:14: error: expected ‘)’ before string constant
[root@linuxguru.symantec.com][ /usr/src ]vi hello-1.c
=
plz compile @ ur end and let me know ?
 
Old 05-02-2008, 06:11 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Do you have the kernel source code installed? Or maybe just the headers? Look in /usr/include/linux and /usr/src
 
Old 05-02-2008, 06:17 AM   #3
vin2008_linux
LQ Newbie
 
Registered: May 2008
Posts: 3

Original Poster
Rep: Reputation: 0
yes I have installed look at the below
[root@linuxguru.symantec.com][ /root ]cd /usr/src/kernels/2.6.23.1-42.fc8-i686/
arch/ crypto/ hello-1.c ipc/ Makefile net/ sound/
block/ drivers/ include/ kernel/ mm/ scripts/ System.map
.config fs/ init/ lib/ Module.symvers security/ usr/
-----------------------------------
Even I tried by copying hello-1.c in same location and then tried
gcc -o hello-1.0 hello-1.c
but its not working?
 
Old 05-02-2008, 06:42 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Did you check /usr/include/linux? On my machine the headers are in /usr/src/<kernelname>/include/linux AND in /usr/include/linux. I don't know if this is significant.
 
  


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
Please help about kernel programming elefer Programming 3 10-29-2006 02:45 PM
Difference between Userland programming and Kernel Programming.. meetsagittarian Programming 1 02-20-2006 12:26 AM
kernel programming help Pratik H Pandya Red Hat 4 09-02-2005 11:54 PM
Kernel Programming. dreamz_jaleel Programming 7 04-15-2005 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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