LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
Thread Tools Search this Thread
Old 11-10-2001, 01:37 AM   #1
Thomas.P
LQ Newbie
 
Registered: May 2001
Posts: 7
Thanked: 0
Smile Kernel Module Programming


[Log in to get rid of this advertisement]
Hi,

I am trying to learn kernel module programming and i'm using the the linux kernel module programming guide. But i cannot even successfully compile the hello world program. The compiler posts a message like " Warning : Kernel version mismatch. The module has been compiled for kernel version 2.4. while this kernel version is 2.2.16".

Please tell me how to compile a module without version dependencies..

Regards,

Thomas
Thomas.P is offline     Reply With Quote
Old 11-10-2001, 11:23 AM   #2
isajera
Senior Member
 
Registered: Jun 2001
Location: San Antonio, TX
Distribution: distro? what's a distro?
Posts: 1,635
Thanked: 0
the kernel version shouldn't defined anywhere in the module - it should have headers to do that.

#include <linux/kernel.h>
#include <linux/module.h>

#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif

int init_module()
{
printk("hello world\n");
return 0;
}

void cleanup_module()
{
}

--- and, that's it for the hello world. it needs to be compiled with

CC=gcc
MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX

hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODFLAGS) -c hello.c



it doesn't do anything, but it should load and unload.
isajera is offline     Reply With Quote

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
experimenting with kernel module programming bravetanveer Linux - General 0 12-30-2004 04:29 AM
Kernel module programming lokutas Programming 2 04-27-2004 03:26 AM
Kernel Module Programming in 2.6 KneeLess Programming 3 04-13-2004 03:27 PM
Kernel Module programming Config Programming 2 03-24-2004 05:48 PM
kernel module programming shellcode Programming 1 02-06-2004 12:43 AM


All times are GMT -5. The time now is 02:25 PM.

Main Menu
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.
Advertisement
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Click Here to receive a complimentary subscription courtesy of LQ.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration