Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
August 1, 2003, 3:47 pm

I have the following bare-bones kernel module...
------------------------------------------------------
#ifndef __KERNEL__
#define __KERNEL__
#define MODULE
#include <linux/module.h>
int init_module(void)
{
printk("<1>Hello, World\n");
return 0;
}
void cleanup_module(void)
{
printk("<1>I'm outta here...\n");
}
#endif
------------------------------------------------------
I compile with...
[blah@localhost blah] gcc -O2 -Wall -D__KERNEL__ -DMODULE
-I/usr/src/linux/include/ -c blah.c
So far no problems. I should point out that this module is intended
for another system, and the sources at /usr/src/linux match that of
the target. When I move blah.o to the other system, I get this...
bash-2.05# /sbin/insmod blah.o
blah.o: couldn't find the kernel version the module was compiled for
Sure... let's try that again...
bash-2.05# /sbin/insmod -f blah.o
blah.o: couldn't find the kernel version the module was compiled for
Could someone shed some light?? TIA
------------------------------------------------------
#ifndef __KERNEL__
#define __KERNEL__
#define MODULE
#include <linux/module.h>
int init_module(void)
{
printk("<1>Hello, World\n");
return 0;
}
void cleanup_module(void)
{
printk("<1>I'm outta here...\n");
}
#endif
------------------------------------------------------
I compile with...
[blah@localhost blah] gcc -O2 -Wall -D__KERNEL__ -DMODULE
-I/usr/src/linux/include/ -c blah.c
So far no problems. I should point out that this module is intended
for another system, and the sources at /usr/src/linux match that of
the target. When I move blah.o to the other system, I get this...
bash-2.05# /sbin/insmod blah.o
blah.o: couldn't find the kernel version the module was compiled for
Sure... let's try that again...
bash-2.05# /sbin/insmod -f blah.o
blah.o: couldn't find the kernel version the module was compiled for
Could someone shed some light?? TIA

Re: Could someone please answer a stupid question...

Are you running this classic in X-Windows? If so, your "Hello, World"
message should appear in /var/log/messages.
Are you wondering what you can do to make the kernel version message go
away? Skip up to page 26, and try
#define __NO_VERSION__
// before
#include <linux/module.h>
I'm going to fire up the source for a simple driver which I was working
on, and let you know if I see anything else.
I hope this works, one or the other, or both.
- Pat
kohli at ameritel.net
PS, I'm assuming that you are using Rubini and Corbet's O'Reilly book as
an aid. If so, what is yor impression?

Re: Could someone please answer a stupid question...

Sorry it's taken me this long to reply... I did get this to work,
although I honestly don't know what I did differently to get this to
work...

I know... problem was that I never got this far... the module would
compile without complaint but wouldn't install, even with an '-f'

Thanks, I'll give this a shot next time this comes up (and I have a
feeling it will) :)

I nearly wore that book out my senior year of college :) Also good is
"Understanding the Linux Kernel' by Bovet and Cesati, although it's a
bit more dated.

Re: Could someone please answer a stupid question...

This is taken from the computer you compile at...
And does not match the targets.
You should/could set up a mirror of the target in some directory
(like ~/target) and then compile with
gcc -nostdinc -I ~/target/include -nostdlib ...
/RogerL
--
Roger Larsson
Skellefteå
Roger Larsson
Skellefteå
We've slightly trimmed the long signature. Click to see the full one.
Site Timeline
- » linux 2.2 and usb
- — Next thread in » Embedded Linux
-
- » linux and rs-485
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » Quanta corrente potràfornire?
- — The site's Newest Thread. Posted in » Electronics Hobby (Italian)
-