On Mon, Dec 10, 2007 at 05:02:26PM +0530, Thippeswamy, Aravind wrote: > I am facing problems while I try to compile a simple "Hello > World" Kernel module. I am using RHEL 5 (2.6.12.x kernel). > > This is the program that I am trying to compile. > > /************************* Hello World Kernel Module > *********************/ #define MODULE #define LINUX #define __KERNEL__ Don't define that, kbuild will do that for you. > > #include <linux/module.h> /* Needed by all modules */ #include > <linux/kernel.h> /* Needed for KERN_ALERT */ > > int init_module(void) > { > printk("<1>Hello world 1.\n"); Use KERN_ALERT instead of "<1>". > // A non 0 return means init_module failed; module can't be loaded. > return 0; > } > > void cleanup_module(void) > { > printk(KERN_ALERT "Goodbye world 1.\n"); } > > MODULE_LICENSE("GPL"); > > /*************************** End of the Module > ***************************/ > > The make file that I am using is > > /************************* Hello World Makefile > *************************/ > > obj-m += hello-1.o > > all: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules > > clean: > make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean That should be OK. > /*************************** End of the Makefile *******************/ > > The error that I am getting is that > > "/lib/modules/$(shell uname -r)/build cannot be found" or something like > that. Please be specific with error messages. "Something like that" can be anything, it's just as annoying as "it doesn't work". > I did find the "/lib/modules/$(shell uname -r)/build", but there was > nothing in it. I am facing this only when I try this with RHEL 5 or FC > 7. Install the kernel source or header packages. Usually called something like "linux-xxx-headers" or "linux-xxx-dev" or so. Erik -- They're all fools. Don't worry. Darwin may be slow, but he'll eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
Attachment:
signature.asc
Description: Digital signature