All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: "Ilan S." <ilan_sk@netvision.net.il>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 'hello world' module
Date: Sat, 11 Jun 2005 21:43:40 +0200	[thread overview]
Message-ID: <9a8748490506111243314d811@mail.gmail.com> (raw)
In-Reply-To: <200506111511.02581.ilan_sk@netvision.net.il>

On 6/11/05, Ilan S. <ilan_sk@netvision.net.il> 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@gmail.com>
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

  parent reply	other threads:[~2005-06-11 19:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-11 12:11 'hello world' module Ilan S.
2005-06-11 18:17 ` Sam Ravnborg
2005-06-11 20:25   ` Jan Engelhardt
2005-06-12 19:17     ` Sam Ravnborg
2005-06-11 19:43 ` Jesper Juhl [this message]
2005-06-13 20:09 ` Edward Macfarlane Smith
  -- strict thread matches above, loose matches on Subject: below --
2005-06-11 15:53 Nick Warne
     [not found] <4egz4-2tj-15@gated-at.bofh.it>
2005-06-11 16:25 ` Robert Hancock
2005-06-11 16:31   ` Jan Engelhardt
2005-06-11 16:54 Nick Warne
2005-06-11 17:06 ` Jan Engelhardt
2005-06-13 17:50 Nick Warne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a8748490506111243314d811@mail.gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=ilan_sk@netvision.net.il \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.