[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

compiling module



Hi,
I have problem to compile a small module example here is hello.c

#include <linux/kernel.h>
#include <linux/module.h>

int init_module(){
printk(KERN_DEBUG "Hello Kernel");
return 0;
}
void cleanup_module(){
printk(KERN_DEBUG "Good Bye Kernel");
}

I compile it with the command
gcc -D__KERNEL__ -I/usr/src/linux/include/ -DMODULE -Wall -O2 -c hello.c
-o hello.o

uname -a gives
Linux belaptop 2.6.26-1-686 #1 SMP Mon Dec 15 18:15:07 UTC 2008 i686
GNU/Linux

ls -l /usr/src
lrwxrwxrwx 1 root src 19 2009-01-02 15:47 linux -> linux-source-2.6.26
drwxr-xr-x 18 root root 4096 2009-01-02 18:59 linux-headers-2.6.26-1-common
drwxr-xr-x 3 root root 4096 2009-01-02 18:59 linux-kbuild-2.6.26
drwxr-xr-x 21 root root 4096 2009-01-02 19:10 linux-source-2.6.26
drwxr-xr-x 4 root root 4096 2009-01-06 09:54 linux-headers-2.6.26-1-686

I got a lot of errors, here is the beginning:



gcc -D__KERNEL__ -I/usr/src/linux/include/ -DMODULE -Wall -O2 -c hello.c
-o hello.o
In file included from /usr/src/linux/include/linux/prefetch.h:14,
from /usr/src/linux/include/linux/list.h:6,
from /usr/src/linux/include/linux/module.h:9,
from hello.c:11:
/usr/src/linux/include/asm/processor.h:112: error:
‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
/usr/src/linux/include/asm/processor.h:112: error: requested alignment
is not a constant
In file included from /usr/src/linux/include/linux/prefetch.h:14,
from /usr/src/linux/include/linux/list.h:6,
from /usr/src/linux/include/linux/module.h:9,
from hello.c:11:




I suspect the version:
I installed 2.6.26.11 then 2.6.26.12, but both generate the same vmlinuz
but not same initrd
Here is a part of /usr/src/linux/include/asm, I have 2 dates, probably
one came from version 26.11 ( 2008-07-13 ) and other from 26.12
(2008-12-15 )??????

-rw-r--r-- 1 root root 6534 2008-07-13 22:51 alternative.h
-rw-r--r-- 1 root root 289 2008-07-13 22:51 alternative-asm.h
-rw-r--r-- 1 root root 1137 2008-07-13 22:51 agp.h
-rw-r--r-- 1 root root 4833 2008-07-13 22:51 acpi.h
drwxr-xr-x 2 root root 4096 2008-12-15 13:05 xen
-rw-r--r-- 1 root root 5896 2008-12-15 13:05 vm86.h
-rw-r--r-- 1 root root 6909 2008-12-15 13:05 spinlock.h
-rw-r--r-- 1 root root 5527 2008-12-15 13:05 signal.h
-rw-r--r-- 1 root root 14834 2008-12-15 13:05 pgtable.h


So I have neither the source of 2.6.26.11 nor the source of 2.6.26.12 ???
Am I right ?

How to fix it

Thanks for help
best regards
bela













Reply to: