Re: 'hello world' module
From: Jesper Juhl
Date: Sat Jun 11 2005 - 14:48:32 EST
On 6/11/05, Ilan S. <ilan_sk@xxxxxxxxxxxxxxxx> wrote:
> 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.
--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/