* compiling "hello world" kernel module on 2.6 kernel
@ 2005-05-07 13:19 li nux
2005-05-07 14:05 ` Espen Fjellvær Olsen
0 siblings, 1 reply; 4+ messages in thread
From: li nux @ 2005-05-07 13:19 UTC (permalink / raw)
To: linux
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compiling "hello world" kernel module on 2.6 kernel
2005-05-07 13:19 compiling "hello world" kernel module on 2.6 kernel li nux
@ 2005-05-07 14:05 ` Espen Fjellvær Olsen
0 siblings, 0 replies; 4+ messages in thread
From: Espen Fjellvær Olsen @ 2005-05-07 14:05 UTC (permalink / raw)
To: li nux; +Cc: linux
On 5/7/05, li nux <lnxluv@yahoo.com> wrote:
>
> default:
> $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
Try changing this to:
" $(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) modules"
--
Mvh / Best regards
Espen Fjellvær Olsen
espenfjo@gmail.com
Norway
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compiling "hello world" kernel module on 2.6 kernel
@ 2005-05-07 14:20 li nux
2005-05-08 18:32 ` Sam Ravnborg
0 siblings, 1 reply; 4+ messages in thread
From: li nux @ 2005-05-07 14:20 UTC (permalink / raw)
To: Espen "Fjellvær" Olsen; +Cc: linux
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 973 bytes --]
Thanks Espen, but it didnt worked.
Please tell me where i am wrong:
hello.c is at /local/usr/linux-2.6.5-7.162
i did a cd to /local/usr/linux-2.6.5-7.162
created makefile called Makefile.1 as u suggested.
and did a make -f Makefile.1
--- Espen Fjellvær Olsen <espenfjo@gmail.com> wrote:
> On 5/7/05, li nux <lnxluv@yahoo.com> wrote:
> >
> > default:
> > $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
>
> Try changing this to:
> " $(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) modules"
>
>
> --
> Mvh / Best regards
> Espen Fjellvær Olsen
> espenfjo@gmail.com
> Norway
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
Discover Yahoo!
Find restaurants, movies, travel and more fun for the weekend. Check it out!
http://discover.yahoo.com/weekend.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: compiling "hello world" kernel module on 2.6 kernel
2005-05-07 14:20 li nux
@ 2005-05-08 18:32 ` Sam Ravnborg
0 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2005-05-08 18:32 UTC (permalink / raw)
To: li nux; +Cc: Espen "Fjellv?r" Olsen, linux
On Sat, May 07, 2005 at 07:20:26AM -0700, li nux wrote:
> Thanks Espen, but it didnt worked.
> Please tell me where i am wrong:
> hello.c is at /local/usr/linux-2.6.5-7.162
> i did a cd to /local/usr/linux-2.6.5-7.162
> created makefile called Makefile.1 as u suggested.
> and did a make -f Makefile.1
Wrong.
Put hello.c somewhere in you home directory.
The Makefile shall be placed in same directory.
Restore any files you have overwritten in the kernel dir (like the
Makefile)
Then it will work out.
If not post full details including the output of the make command with
V=1 included: $(MAKE) -C $(KERNELDIR) V=1 M=$(PWD)
Sam
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-08 18:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-07 13:19 compiling "hello world" kernel module on 2.6 kernel li nux
2005-05-07 14:05 ` Espen Fjellvær Olsen
-- strict thread matches above, loose matches on Subject: below --
2005-05-07 14:20 li nux
2005-05-08 18:32 ` Sam Ravnborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).