From: Erik Mouw <erik@harddisk-recovery.com>
To: "Srinivas G." <srinivasg@esntechnologies.co.in>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Small problem, Can anybody help me?
Date: Thu, 6 May 2004 16:28:27 +0200 [thread overview]
Message-ID: <20040506142827.GI15056@harddisk-recovery.com> (raw)
In-Reply-To: <1118873EE1755348B4812EA29C55A97222F512@esnmail.esntechnologies.co.in>
On Thu, May 06, 2004 at 07:31:56PM +0530, Srinivas G. wrote:
> I have written a small hello.c program in the Linux Kernel version
> 2.4.18-3.
Ancient kernel with lots of known bugs and security issues. You'd
rather upgrade.
> The code is as follows.
> -----------------------
>
>
> define MODULE
The idea is to put that definition on the gcc command line.
> #include <linux/module.h>
> #include <linux/init.h>
You're missing #include <linux/kernel.h>
> MODULE_LICENSE("GPL");
>
> int Test_init(void)
> {
> printk("<1> Hello World\n");
Use KERN_ALERT instead of "<1>". We have #defines for a reason: if we
change the definition tomorrow, your source will still work. So use:
printk(KERN_ALERT "Hello, world!\n");
> return 0;
> }
>
> void Test_cleanup(void)
> {
> printk("<1> Good bye\n");
> }
>
> module_init(Test_init);
> module_exit(Test_cleanup);
>
>
> I compiled it under same kernel version that is 2.4.18-3. It was showing
> the following errors.
>
> In file included from hello.c:2:
> /usr/include/linux/module.h:60: parse error before `atomic_t'
^^^^^^^^^^^^
You're compiling against libc headers instead of kernel headers. See:
http://www.kernelnewbies.org/faq/index.php3#headers
The way to compile a module on linux 2.4 is:
gcc -O2 -Wall -I/path/to/kernel/include/directory -D__KERNEL__ -DMODULE -c hello.c
Erik
--
+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands
next prev parent reply other threads:[~2004-05-06 14:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-06 14:01 Small problem, Can anybody help me? Srinivas G.
2004-05-06 14:28 ` Erik Mouw [this message]
2004-05-06 17:27 ` David Woodhouse
2004-05-06 14:33 ` Dave Jones
2004-05-06 15:47 ` Richard B. Johnson
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=20040506142827.GI15056@harddisk-recovery.com \
--to=erik@harddisk-recovery.com \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivasg@esntechnologies.co.in \
/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