View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 02-23-2006, 07:36 AM   #1
LQ Newbie
Registered: Dec 2005
Distribution: Ubuntu
Posts: 5

Rep: Reputation: 0
Unhappy module compilation fails

Hi all,

I tried to compile a simple module on linux and saw a bunch of errors:

Module code:

1 #define MODULE
2 #include <linux/module.h>
4 int init_module(void) { printk("<1>Hello, world\n"); return 0; }
5 void cleanup_module(void) { printk("<1>Goodbye cruel world\n"); }


"gcc -c hello.c"

In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from hello.c:2:
/usr/include/linux/signal.h:2:2: warning: #warning "You should include <signal.h>. This time I will do it for you."
In file included from /usr/include/linux/resource.h:4,
from /usr/include/linux/sched.h:79,
from /usr/include/linux/module.h:9,
from hello.c:2:
/usr/include/linux/time.h:9: error: redefinition of ‘struct timespec’
/usr/include/linux/time.h:15: error: redefinition of ‘struct timeval’
/usr/include/linux/time.h:20: error: redefinition of ‘struct timezone’
/usr/include/linux/time.h:47: error: redefinition of ‘struct itimerval’
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

I am running Ubuntu 5.10 "Breezy Badger", on kernel

Maybe anyone knows where the problem is?

Thanx a lot.

Last edited by taux; 02-23-2006 at 07:47 AM.
Old 02-23-2006, 04:50 PM   #2
LQ Newbie
Registered: Dec 2005
Distribution: Ubuntu
Posts: 5

Original Poster
Rep: Reputation: 0
Lightbulb solved

Allready solved the problem. 2.6 kernel seems to have specialised module compilation. You have to write such makefile:

obj-m := hello.o
KDIR := /usr/src/linux/linux-
PWD := $(shell pwd)
   $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules


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
kernel compilation fails hard elwoodblues Linux - Laptop and Netbook 0 09-16-2005 03:56 AM
Module Compilation thirumalai Linux - Software 0 08-13-2004 12:20 AM
ALSA RPM rebuild fails, other compilation problems abro Linux - Software 3 12-09-2003 07:34 PM
module compilation aliyildiz Linux - General 6 03-31-2003 03:11 PM
module compilation aliyildiz Linux - General 0 12-08-2001 01:53 PM

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration