LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-14-2004, 12:14 PM   #1
fvarela
LQ Newbie
 
Registered: Jul 2004
Posts: 1

Rep: Reputation: 0
Unhappy how to compile a module with a newer version of the linux kernel?


Hi,

I am trying to write a custom module. The Linux kernel version is 2.6.6-1.435. For some reason, the source code version installed in my notebook was 2.6.5-1.358. Although I could compile my module, I could not loaded using insmod due to an error with VERMAGIC.
I decided to download the version which corresponds to the installed kernel version. After downloading the source code, I did:

root% rpm -Uvh kernel-sourcecode-2.6.6-1.435.2.3.noarch.rpm

The problem now is that the module does not compile. These are some of the errors I get:

------
[root@phy2-dhcp230 new]# make -C /usr/src/linux-2.6.6-1.435.2.3/ SUBDIRS=$PWD modules

make: Entering directory `/usr/src/linux-2.6.6-1.435.2.3'
Makefile:434: .config: No such file or directory
CC [M] /home/fvarela/bu/linux/drivers/v26/new/newkhello.o
In file included from include/linux/module.h:9,
from /home/fvarela/bu/linux/drivers/v26/new/newkhello.c:1:
include/linux/config.h:4:28: linux/autoconf.h: No such file or directory
In file included from include/linux/module.h:10,
from /home/fvarela/bu/linux/drivers/v26/new/newkhello.c:1:
include/linux/sched.h:4:37: asm/param.h: No such file or directory
In file included from include/linux/types.h:13,
from include/linux/capability.h:16,
from include/linux/sched.h:7,
from include/linux/module.h:10,
from /home/fvarela/bu/linux/drivers/v26/new/newkhello.c:1:
include/linux/posix_types.h:47:29: asm/posix_types.h: No such file or directory
In file included from include/linux/capability.h:16,
from include/linux/sched.h:7,
from include/linux/module.h:10,
from /home/fvarela/bu/linux/drivers/v26/new/newkhello.c:1:
include/linux/types.h:14:23: asm/types.h: No such file or directory
In file included from include/linux/capability.h:16,
from include/linux/sched.h:7,

------

I guess this has something to do with the installation of the new source code, and maybe in particular, with the #include sentences that I use that maybe are still pointing to the old source:

#include <linux/module.h>
#include <linux/config.h>
#include <linux/init.h>

1.- What else do I need to do in order to compile my module with the newer version of the kernel source?

2.- Will I gain anything if I compile the new version of the kernel?

Thanx,
F.
 
Old 07-15-2004, 03:23 AM   #2
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
the 2.5+ line of kernels changed the module handling ...now a .o file is not used as a module, but a .ko (kernel object ) file is generated ..
read the documentation/kbuild/makefiles.txt to understand the kernel makefile...

do #include <linux/kernel.h>

a simple make would do.

you'd need new modutils to be able to insmod the modules on 2.6.
available at :
http://www.kernel.org/pub/linux/kern...rusty/modules/

read a file called: post-halloween-2.6.txt

install carefully so that you dont break the insmod'ing for older kernels..

hope this helped
use this makefile
Code:
ifneq ($(KERNELRELEASE),)
obj-m := <module-name>.o

else
 KDIR:= /lib/modules/$(shell uname -r)/build
CC := gcc
CFLAGS  := -c -nostdinc \
-D__KERNEL__ -I /$(KDIR) \
 -I /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/

PWD := $(shell pwd)

default :
make -C $(KDIR) SUBDIRS=$(PWD) modules
clean :
rm *.o *.ko
endif
 
Old 07-29-2004, 02:00 AM   #3
cjs_pro
LQ Newbie
 
Registered: Jul 2004
Posts: 8

Rep: Reputation: 0
Have a look at the linux source directory (rpm'ed). You may find the real soure code still in form of tar.bz2. If so, unzip it and (maybe) make a symbol link to the source directory as well if your module makefile looks at something like /usr/src/linux.

God luck
 
  


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
compile kernel module got version mismatched? blackzone Programming 1 11-07-2004 09:41 PM
Unable to build NVIDIA kernel module / determin kernel version Night Ink Fedora 2 05-31-2004 04:54 PM
Xfree Error (EE) module ABI minor version (7) is newer than the server's version (6) jimdaworm Slackware 0 10-17-2003 05:26 PM
Xfree prob radeon.o kernel module version is 1.1.1 but version 1.5.0 or newer needed. jimdaworm Slackware 0 10-01-2003 06:27 PM
Sample Driver Module incompatibility with Kernel version (or gcc version) jvs Linux - General 1 06-07-2002 01:40 AM


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

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.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration