LinuxQuestions.org
Review your favorite Linux distribution.
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 11-10-2001, 12:37 AM   #1
Thomas.P
LQ Newbie
 
Registered: May 2001
Posts: 7

Rep: Reputation: 0
Smile Kernel Module Programming


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
 
Old 11-10-2001, 10:23 AM   #2
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
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.
 
  


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

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

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