LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-11-2004, 09:56 PM   #1
jeson_515
LQ Newbie
 
Registered: Jul 2003
Location: china
Posts: 12

Rep: Reputation: 0
version problem


I am just beginning kernel programming.When I compile a hello Work module and ins-mod it ,I got this message :
hello was compiled for kernel version 2.4.20 while this kernel is version 2.4.20-8
Should I update my kernel ?
 
Old 03-11-2004, 11:18 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Hypothetical situation. Let's say you're in school, studying kernel programming. You have 2.4.20 at home, 2.4.20-8 at school. You have two options: update your kernel at home,so that you're working with the same kernel at both locations. Or, make two copies of the file you want to compile. Compile one at home; the other at school.
 
Old 03-11-2004, 11:27 PM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Kernel modules are not portable. They look for the specific kernel they were compiled on. Ok, not the specific kernel persay, but a kernel that reports the exact same server string. The best thing to do is like bigrig said, always build the module against the kernel you intend to use it with. Transfer source code, not binaries.
 
Old 03-11-2004, 11:31 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
or you can just insmod -f it iirc, cant u?
 
Old 03-12-2004, 04:42 AM   #5
jeson_515
LQ Newbie
 
Registered: Jul 2003
Location: china
Posts: 12

Original Poster
Rep: Reputation: 0
Firstly,thank you all!
but the problem is that I only have one system ,I compile it just on the same kernel .
 
Old 11-12-2004, 10:42 AM   #6
klopex
LQ Newbie
 
Registered: Nov 2004
Location: USA
Distribution: Redhat, Mandrake
Posts: 9

Rep: Reputation: 0
Add the following to your gcc command line. It appears to fix the error for me. There will still be a warning about there being no license and therefore it might taint the kernel, but the kernel version problem seems to go away.

(You might need to put some version information after linux in the path. Search your filesystem to see what the correct path would be.)
-isystem /usr/src/linux/include

This is the command line that worked for me in the hello world module from "Linux Device Drivers" 2nd Edition. ( I defined __KERNEL__ and MODULE in the code.)
gcc -c -isystem /usr/src/linux/include hello.c
 
  


Reply



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
Regarding distribution + kernel version + gcc version + glib version. JCipriani Linux - General 8 04-19-2008 02:54 PM
automake version problem davidsrsb Slackware 1 02-23-2005 10:09 PM
version 9, reinstall problem dtra Red Hat 4 11-09-2004 06:33 PM
Solaris Problem version 8 David@330 Linux - Newbie 2 07-23-2004 04:22 AM
problem with compiler version?? miha Linux - General 4 01-03-2004 12:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:42 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