I have written a minimal hello world kernel module.
(see the Makefile and hello.c below)
But I am not able to build it using the kernel build
system.Any idea why this is happening.
I referred "Chapter 2: Building and Running Modules"
of
http://www.oreilly.com/catalog/linuxdrive3/book/index.csp
I am using SLES9
My kernel sources are at /local/usr/linux-2.6.5-7.162
This is the kernel i am running.
On doing a make it gives me following output, but does
not build hello.o
----------------------------------------------
$ make
make -C /lib/modules/2.6.5-7.162-bigsmp/build
M=/local/usr/linux-2.6.5-7.162 modules
make[1]: Entering directory
`/local/usr/linux-2.6.5-7.162'
Building modules, stage 2.
MODPOST
make[1]: Leaving directory
`/local/usr/linux-2.6.5-7.162'
--------------------------------------------------
This is my Makefile:
# If KERNELRELEASE is defined, we've been invoked from
# the kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
---------------------------------------------------
hello.c
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/version.h>
#include <linux/vermagic.h>
static int __init hello_init (void)
{
printk("module hello loading");
return 0;
}
static void __exit hello_exit (void)
{
printk("module hello exiting");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE ("GPL");
--------------------------------------------------
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]