Could someone please answer a stupid question...

Aug 01, 2003 3 Replies

I have the following bare-bones kernel module...



------------------------------------------------------ #ifndef __KERNEL__ #define __KERNEL__ #define MODULE #include



int init_module(void) { printk("Hello, World\n"); return 0; }



void cleanup_module(void) { printk("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


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

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?

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å Sweden

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.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required