LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-24-2007, 06:56 AM   #1
yannifan
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Ubuntu Feisty, Fedora 6 dual boot
Posts: 36

Rep: Reputation: 15
Compiling object file for kernel module


Hello ppl,

I have a problem in compiling a kernel source. Iis a basic Hello world source...
I installed kernel source tree in /usr/src/linux-source-2.6.15.x

The hello.c file is placed in a home directory... The command for compiling used is
a) gcc -D__KERNEL__ -I /usr/src/linux-source-2.6.15/include -DMODULE -c hello.c -o hello.o
b) gcc -D__KERNEL__ -I /usr/include -DMODULE -c hello.c -o hello.o

Hello.c is in the present working dir... Command a refers the kernel tree got from kernel.org
Command b uses the include files present in Ubuntu by default.

The errors are :
for a) /usr/include/linux/types.h:4:23: error: sys/types.h: No such file or directory
/usr/include/linux/types.h:4:23: error: sys/types.h: No such file or directory
/usr/include/asm-i386/page.h:4:20: error: unistd.h: No such file or directory
/usr/include/linux/signal.h:4:20: error: signal.h: No such file or directory
In file included from /usr/include/linux/module.h:9,
from hello.c:2:
/usr/include/linux/sched.h:77:22: error: sys/time.h: No such file or directory
In file included from hello.c:2:



for b)
/usr/include/linux/types.h:4:23: error: sys/types.h: No such file or directory
/usr/lib/gcc/i486-linux-gnu/4.0.3/include/asm/posix_types.h:13:22: error: features.h: No such file or directory
/usr/include/asm-i386/page.h:4:20: error: unistd.h: No such file or directory
/usr/include/linux/signal.h:4:20: error: signal.h: No such file or directory
In file included from /usr/include/linux/module.h:9,
from hello.c:2:
/usr/include/linux/sched.h:77:22: error: sys/time.h: No such file or directory
In file included from hello.c:2:
/usr/include/linux/module.h:41: error: field ‘attr’ has incomplete type
/usr/include/linux/module.h:49: error: field ‘kobj’ has incomplete type


Im completely confused... Plsssssss help
Thanks in advance
Cheers
 
Old 02-24-2007, 07:40 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,375

Rep: Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911Reputation: 1911
Basically you miss some C headers, that is *.h files. The ones listed in the error message are from glibc_devel package, at least on OpenSuSE. Depending on your distribution, you have to install the package containing the headers prior to compile hello.c. It would be helpful if you fill the "distribution" field in your LQ profile: answer to questions could be more accurate by knowing some detail on your system. Cheers
 
Old 02-25-2007, 12:55 AM   #3
yannifan
Member
 
Registered: Feb 2007
Location: Bangalore, India
Distribution: Ubuntu Feisty, Fedora 6 dual boot
Posts: 36

Original Poster
Rep: Reputation: 15
Distro

Am so sorry... completely forgot abt the distro... Am using Ubuntu Dapper Drake... Ill try the suggestion and get bak..
thanks
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking precompile archive/object files with kernel module possible? Mechanic Linux - General 0 08-25-2006 02:08 PM
How to write a kernel module(kernel object, .ko) on linux-2.6.0? oskernel Programming 1 10-21-2003 02:20 PM
How to write a kernel module(kernel object, .ko) on linux-2.6.0? oskernel Linux - Software 2 10-18-2003 06:04 AM
Compiling a module/Kernel mismatch fbarre Linux - Newbie 2 09-04-2003 08:26 PM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM


All times are GMT -5. The time now is 03:05 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration