From: "Fernando Barsoba" <fbarsoba@hotmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-kernel@vger.kernel.org
Subject: Re: problems compiling kernel module
Date: Wed, 19 Apr 2006 10:59:58 -0400 [thread overview]
Message-ID: <BAY114-F27D0D25E7FF85033ED93D2C7C50@phx.gbl> (raw)
In-Reply-To: <20060419142442.GC24807@harddisk-recovery.com>
Thanks a lot for your makefile. It worked nicely. I wasn't sure if the
question was too basic for this mailing list.
Thanks also for Arjan's reference to
http://fxr.watson.org/fxr/source/Documentation/kbuild/makefiles.txt?v=linux-2.6.9
I am new in kernel programming...
tnx,
Fernando
>From: Erik Mouw <erik@harddisk-recovery.com>
>To: Fernando Barsoba <fbarsoba@hotmail.com>
>CC: linux-kernel@vger.kernel.org
>Subject: Re: problems compiling kernel module
>Date: Wed, 19 Apr 2006 16:24:42 +0200
>
>On Wed, Apr 19, 2006 at 09:44:08AM -0400, Fernando Barsoba wrote:
> > I am really stuck with this thing.. For couple of days i have been
> > trying to compile a kernel module. I have been following the info in
> > http://www.faqs.org/docs/kernel/x204.html. But no success... i
> > recompiled the latest kernel version, and i think i trying to compile
> > the module against the source code for that kernel.. however, strange
> > errors appear.
>
>That way just doesn't work. Use kbuild instead of brewing your own
>Makefiles. See http://lwn.net/Articles/21823/ .
>
> > And here are the files:
> >
> > Code:
> >
> > /* hello-1.c - The simplest kernel module.
> > */ #include <linux/module.h> /* Needed by all modules
>
>Not necessary, IIRC.
>
> > */ #include <linux/kernel.h> /* Needed for KERN_ALERT */
>
>OK...
>
> > int init_module(void) {
> > printk("<1>Hello world 1.\n"); // A non 0 return means init_module
>
>... so why don't you use KERN_ALERT instead of <1>?
>
>Make that printk(KERN_ALERT "Hello, world!\n");
>
> > failed; module can't be loaded.
> > return 0;
> > }
> >
> > void cleanup_module(void) {
> > printk(KERN_ALERT "Goodbye world 1.\n");
> > }
> >
> >
> > Code:
> >
> > TARGET := hello-1
> > WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
> > INCLUDE := -isystem /lib/modules/`uname -r`/build/include
> > CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE} CC := gcc
> > ${TARGET}.o: ${TARGET}.c
> > .PHONY: clean
> > clean: rm -rf {TARGET}.o
>
>You want something like:
>
>ifneq ($(KERNELRELEASE),)
>obj-m := hello.o
>else
>KDIR := /lib/modules/$(shell uname -r)/build
>PWD := $(shell pwd)
>
>default:
> $(MAKE) -C $(KDIR) M=$(PWD) modules
>endif
>
>
>Erik
>
>--
>+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
>| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands
>-
>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/
next prev parent reply other threads:[~2006-04-19 15:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-19 13:44 Fernando Barsoba
2006-04-19 14:24 ` Erik Mouw
2006-04-19 14:59 ` Fernando Barsoba [this message]
2006-04-19 14:26 ` Arjan van de Ven
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=BAY114-F27D0D25E7FF85033ED93D2C7C50@phx.gbl \
--to=fbarsoba@hotmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®