'hello world' module
Hello dear professionals!
I would be very thankful if anybody prompt me what's wrong. I'm trying to build the "Hello world" module from O'Reilly's "Linux device drivers" and that is what I get:
[ilanso@Netvision Kernel]$ make -C /home/ilanso/src/linux-2.6.11.11 M=pwd
make: Entering directory `/home/ilanso/src/linux-2.6.11.11'
Building modules, stage 2.
MODPOST
make: Leaving directory `/home/ilanso/src/linux-2.6.11.11' [ilanso@Netvision Kernel]$ lshello.c Makefile
[ilanso@Netvision Kernel]$
Please email me to [email protected], because I'm not subscribed to this mailing list yet...
Thanks in advance...
Quoted 6 lines · Ilan S.
Hello dear professionals!
I would be very thankful if anybody prompt me what's wrong. I'm trying to build the "Hello world" module from O'Reilly's "Linux device drivers" and that is what I get:
Quoted 8 lines
[ilanso@Netvision Kernel]$ make -C
/home/ilanso/src/linux-2.6.11.11M=pwd
make: Entering directory `/home/ilanso/src/linux-2.6.11.11'
Building modules, stage 2.
MODPOST
make: Leaving directory `/home/ilanso/src/linux-2.6.11.11' [ilanso@Netvision Kernel]$ lshello.cMakefile
[ilanso@Netvision Kernel]$
Can you please post your Makefile - seems something is wrong here. You could also try to post the output with the V=1 flagg added when invoking make.
Sam
Quoted 2 lines
Quoted 2 lines
[ilanso@Netvision Kernel]$ make -C
/home/ilanso/src/linux-2.6.11.11M=pwd
Try adding "modules" at the end?
Quoted 4 lines · Jan Engelhardt
Quoted 2 lines
Quoted 2 lines
[ilanso@Netvision Kernel]$ make -C
/home/ilanso/src/linux-2.6.11.11M=pwdTry adding "modules" at the end?
In 2.6 thats implicit when using M=... syntax.
Sam
Quoted 6 lines · Ilan S.
Hello dear professionals!
I would be very thankful if anybody prompt me what's wrong. I'm trying to build the "Hello world" module from O'Reilly's "Linux device drivers" and that is what I get:
I don't have that book, so I can't really say, but here's an example from "Linux Kernel Development, 2ed" by rml
(http://rlove.org/kernel_book/)
/*
* hello.c - Hello, World! As a Kernel Module
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
/*
* hello_init - the init function, called when the module is loaded.
* Returns zero if successfully loaded, nonzero otherwise. */
static int hello_init(void)
{
printk(KERN_ALERT "I bear a charmed life.\n");
return 0;
}/*
* hello_exit - the exit function, called when the module is removed. */
static void hello_exit(void)
{
printk("KERN_ALERT "out, out, brief candle!\n");
}module_init(hello_init);module_exit(hello_exit);
MODULE_LICENSE("GPL");MODULE_AUTHOR("Shakespeare");
To build the module above, make a Makefile in the same dir with this line in it :
obj-m := hello.o
Then build like this:
make -C /kernel/source/location SUBDIRS=$PWD modules
Works for me :)
Of course there's lots of additional info in the book. Robert wrote a rather good one, it's well worth checking out if you ask me.
Signature · 3 lines
Jesper Juhl <[email protected]> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html
Quoted 6 lines · Ilan S.
Hello dear professionals!
I would be very thankful if anybody prompt me what's wrong. I'm trying to build the "Hello world" module from O'Reilly's "Linux device drivers" and that is what I get:
Quoted 9 lines
[ilanso@Netvision Kernel]$ make -C
/home/ilanso/src/linux-2.6.11.11M=pwd
make: Entering directory `/home/ilanso/src/linux-2.6.11.11'
Building modules, stage 2.
MODPOST
make: Leaving directory `/home/ilanso/src/linux-2.6.11.11' [ilanso@Netvision Kernel]$ lshello.cMakefile
[ilanso@Netvision Kernel]$
Hi Ilan,
I've been working through this book too, not sure why it's not working for you. Have you actually built the kernel in the directory you're pointing it at? I was able to use the command:
make -C /usr/src/linux M=pwd
where my Makefile had
obj-m := eaglenet.o
The makefile I've generally used that works fine (so you can just type make) was:
ifneq ($(KERNELRELEASE),)
obj-m := eaglenet.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
Where my module was eaglenet.
Regards,
Edward