LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-31-2005, 04:10 AM   #1
3-1415
LQ Newbie
 
Registered: Jul 2004
Location: Kyiv
Distribution: Mandrake, ASP, Slackware, W2k
Posts: 19

Rep: Reputation: 0
Help. can't compile kernel module properly


Hi all
I am a newbie in kernel programming and of course faced such a trouble
I have 2 PCs with Slackware 10.0 and generic kernel vmlinuz-ide-2.4.29 installed on both of them. The PC 1-st pc works fine, on the 2-nd pc i can't compile properly the simplest kernel module like this:
Code:
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
  printk("example.o: loaded\n");
  return 0;
}
void cleanup_module(void)
{
   printk("example.o: unloaded...\n");
}
=======================
Makefile:
CC=gcc
module=example
MODFLAGS:= -O3 -Wall -DLINUX
$(module).o:	$(module).c
		$(CC) $(MODFLAGS) -c $^ -o $@
The compilation works without warnings on both pc's, but when i try to load the module on my 2-nd pc i get such an error:
couldn't find the kernel version the module was compiled for
It looks as if i deleted first 2 define strings in the code(#define MODULE and #define __KERNEL__).
Other kernels on the 2-nd pc gives the same result
 
Old 05-31-2005, 09:18 PM   #2
kryptonite0110
Member
 
Registered: Mar 2005
Posts: 59

Rep: Reputation: 15
a book i have on linux programming makes the code look more like this...
Code:
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif

#include <linux/kernel.h>
int init_module(void)
{
  printk("example.o: loaded\n");
  return 0;
}
void cleanup_module(void)
{
   printk("example.o: unloaded...\n");
}
maybe you just needed to include linux/modversions.h?
i'm not much of a kernel modules programmer myself, that's the way i always did it...
 
Old 06-01-2005, 03:54 AM   #3
3-1415
LQ Newbie
 
Registered: Jul 2004
Location: Kyiv
Distribution: Mandrake, ASP, Slackware, W2k
Posts: 19

Original Poster
Rep: Reputation: 0
Unfortunately I can't try You example now, but if the same code works well on 1-st pc and does I can't catch wh the problemn't work properly on 2-nd one, there must be something wrong in system.
 
Old 06-01-2005, 03:56 AM   #4
3-1415
LQ Newbie
 
Registered: Jul 2004
Location: Kyiv
Distribution: Mandrake, ASP, Slackware, W2k
Posts: 19

Original Poster
Rep: Reputation: 0
...Sorry
Unfortunately I can't try You example now, but if the same code works well on 1-st pc and doesn't work properly on 2-nd one, there must be something wrong in system.
 
  


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 compile prob darkRoom Linux - General 3 11-08-2005 01:16 AM
Compile in kernel or module? maginotjr Slackware 4 06-30-2005 12:54 PM
compile module for running kernel maenho Linux - Software 5 06-27-2005 02:44 PM
can't Compile a module under Kernel 2.4.20-8 srsairam Linux - Software 3 11-09-2004 01:45 AM
can i compile just one kernel module whithout recompiling the whole kernel? edman007 Linux - Software 3 02-17-2004 04:05 PM

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

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