LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-04-2003, 02:36 PM   #1
fbarre
LQ Newbie
 
Registered: Aug 2003
Location: California
Distribution: RedHat
Posts: 28

Rep: Reputation: 15
Compiling a module/Kernel mismatch


I'm trying to learn how to write modules and compiled a simple "hello world".
After compilation, I tried loading it with "insmod" but I couldn't
and returns a msg that says:

Kernel mismatch, module compiled with kernel 2.4.9 and the current kernel is 2.4.21.

I don't understand where the 2.4.9 kernel came from because my current kernel is 2.4.21.

thanks,
 
Old 09-04-2003, 03:17 PM   #2
bastard23
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 275

Rep: Reputation: 30
fbarre,

The system include files (/usr/include/linux) are from an older kernel. They are the headers that glibc was compiled against. This is the way it should be. You need to force the include (-I gcc option) to use your current kernel (-I- turns off previous includes). Something like -I- -I/lib/modules/`uname -r`/build/include or where ever your kernel source lives.

Good Luck,
chris

PS Maybe this would be better served in the programming section?
 
Old 09-04-2003, 08:26 PM   #3
fbarre
LQ Newbie
 
Registered: Aug 2003
Location: California
Distribution: RedHat
Posts: 28

Original Poster
Rep: Reputation: 15
Hey Bastard23,

Thanks for your tip, I go it working!
To those of you who might run into the same problem, do:

gcc -c -Wall -I /usr/src/linux/include/ hello.c

- c : to create object file "hello.o"
- Wall: report all warnings, very helpfull to see where the include
files are picked up from.
- I: to look at that directory for include files

note that /usr/src/linux might be a different name in your case such as linux-2.4.21... in my case it's a soft link to /usr/src/linux-2.4.21.

happy linuxing!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel module mismatch vmniza Linux - Newbie 3 02-01-2005 02:44 PM
Kernel-module Version Mismatch !!! lionking_x Linux - Networking 1 02-02-2004 02:07 PM
Kernel-module Version Mismatch !!! lionking_x Linux - Software 1 02-02-2004 02:06 PM
Kernel-module Version Mismatch !!! lionking_x Linux - Newbie 1 02-02-2004 01:01 PM
kernel-module version mismatch louai Linux - General 2 01-08-2004 11:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration