Getting problem while building kernel module

Previous thread: Aggregation in embedded context, is kernel GPL2 prejudice against embedded systems? by Crane, Matthew on Thursday, October 11, 2007 - 7:33 am. (9 messages)

Next thread: Re: 2.6.23 spinlock hang in kswapd under heavy disk write loads by Mr. Berkley Shands on Thursday, October 11, 2007 - 9:23 am. (2 messages)
From: mahamuni ashish
Date: Thursday, October 11, 2007 - 7:53 am

Hi all,
I am trying to build the following module and getting
below specified error.please help me for successful
compilation
here is my code(ins.c)
--------------------------
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
	printk(KERN_ALERT "Hello, world\n");
	return 0;
}

static void hello_exit(void)
{
	printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);
--------------------------
[root@localhost device_driver]# make

gcc -O2 -DMODULE -D__KERNEL__ -isystem 
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include   -c
-o ins.o ins.c
'In file included from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/thread_info.h:16,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/thread_info.h:21,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/preempt.h:9,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/spinlock.h:49,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/capability.h:45,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/sched.h:44,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/module.h:9,
                 from ins.c:2:
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/processor.h:80:
error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here
(not in a function)
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/asm/processor.h:80:
error: requested alignment is not a constant
In file included from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/sched.h:49,
                 from
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/module.h:9,
                 from ins.c:2:
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/jiffies.h:33:3:
error: #error You lose.
/usr/src/kernels/2.6.18-1.2798.fc6-i686/include/linux/jiffies.h:210:31:
error: division by ...
From: Jan Engelhardt
Date: Thursday, October 11, 2007 - 8:01 am

Time to read Documentation/kbuild/.

-

From: Gustavo Chain
Date: Thursday, October 11, 2007 - 8:44 am

El Thu, 11 Oct 2007 15:53:41 +0100 (BST)

here's a little tutorial
http://vmlinux.org/jocke/linux/external-modules-2.6.shtml

kbuild do the trick

-- 
Gustavo Chaín Dumit
Alumno de Ingeniería de Ejecución Informática
Pontificia Universidad Católica de Valparaiso
http://aleph.homeunix.com/~gchain
-

Previous thread: Aggregation in embedded context, is kernel GPL2 prejudice against embedded systems? by Crane, Matthew on Thursday, October 11, 2007 - 7:33 am. (9 messages)

Next thread: Re: 2.6.23 spinlock hang in kswapd under heavy disk write loads by Mr. Berkley Shands on Thursday, October 11, 2007 - 9:23 am. (2 messages)