LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 07-04-2012, 06:24 AM   #1
aijazbaig1
LQ Newbie
 
Registered: Jun 2007
Location: Mumbai, India
Distribution: centos, opensuse
Posts: 15

Rep: Reputation: 0
Question Error compiling loadable kernel module with vanilla kernel


Hello Folks

Ive been trying to compile a vanilla kernel just for the purpose of refreshing some long forgotten loadable modules concepts. By the way, Im running centos 6.

what ive done is, ive downloaded a vanilla kernel image 2.6.32 from kernel.org and then I did a
Code:
menu xconfig
on it to create a .config file. After having done that, I run
Code:
make
on the top level directory which seems to work fine.

However
Code:
make modules
fails with the following errors:

Code:
No rule to make target 'net/ipv4/netfilter/ipt_ecn.c', needed by `net/ipv4/netfilter/ipt_ecn.o'. Stop'
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [net/ipv4/netfilter] Error 2
make[1]: *** [net/ipv4] Error 2
make: *** [net] Error 2
make: *** Waiting for unfinished jobs....
I believe this just means that it was NOT able to build the 'ipt_ecn' module ('iptables' module which is typically used as a filtering, network traffic sniffer/shaper..and many other things. Thats out of topic for this). And thats fine with me. What has got me concerned is, since it apparently failed in the middle, it may have missed out on any book-keeping task(s) which it does at the end of 'make modules'?

Nonetheless, I ran a
Code:
make modules
and it seemed to have went fine (note that ive already installed the modules under /lib/modules/ by doing a
Code:
make modules_install
at the top of the vanilla kernel source tree). I then cd into the directory where my kernel module source code is located. My Makefile in it looks like this:
Code:
obj−m += hello−1.o

all: 
make -C /lib/modules/2.6.32.59/build M=$(shell pwd) modules

clean: 
make -C /lib/modules/2.6.32.59/build M=$(shell pwd) clean
I DID NOT use the /lib/modules/`uname -r`/build path as I do not want to have these modules linked against the currently running kernel. I will only do an 'insmod' after having booted into the '2.6.32.59' vanilla kernel later. So am I allowed to build a kernel module against a kernel which is not currently running?

Anyways, I try doing exactly that, by doing a
Code:
make all
in the directory where I have my kernel module source. However I get the following errors:
Code:
make -C /lib/modules/2.6.32.59/build M=/home/aijazbaig1/modules modules 
make[1]: Entering directory `/home/aijazbaig1/linux-2.6.32.59'
test -e include/linux/autoconf.h -a -e include/config/auto.conf || ( \
echo; \
echo " ERROR: Kernel configuration is invalid."; \
echo " include/linux/autoconf.h or include/config/auto.conf are missing."; \
echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo; \
/bin/false)
mkdir -p /home/aijazbaig1/modules/.tmp_versions ; rm -f /home/aijazbaig1/modules/.tmp_versions/*

WARNING: Symbol version dump /home/aijazbaig1/linux-2.6.32.59/Module.symvers
is missing; modules will have no dependencies and modversions.

make -f scripts/Makefile.build obj=/home/aijazbaig1/modules
(cat /dev/null; ) > /home/aijazbaig1/modules/modules.order
make -f /home/aijazbaig1/linux-2.6.32.59/scripts/Makefile.modpost
scripts/mod/modpost -m -a -i /home/aijazbaig1/linux-2.6.32.59/Module.symvers -I /home/aijazbaig1/modules/Module.symvers -o /home/aijazbaig1/modules/Module.symvers -S -w -s
make[1]: Leaving directory `/home/aijazbaig1/linux-2.6.32.59
After searching a lot over the internet, ive come across many different opinions but I couldn't figure out a single reason as to why it fails to find the autoconf.h or auto.conf files. These files are present under the source tree

[root@MyCentOS-VM linux-2.6.32.59]# find . -name autoconf.h
./include/linux/autoconf.h
[root@MyCentOS-VM linux-2.6.32.59]# find . -name auto.conf
./include/config/auto.conf

Ive also created a soft link (since it wasn't there by default to begin with) '/usr/src/linux' to point to the directory where the stock kernel is located.
Here:
[root@MyCentOS-VM modules]# ls -l /usr/src/
total 8
drwxr-xr-x. 2 root root 4096 Sep 23 2011 debug
drwxr-xr-x. 3 root root 4096 Jun 27 16:08 kernels
lrwxrwxrwx. 1 root root 33 Jul 2 16:05 linux -> /home/aijazbaig1/linux-2.6.32.59/

I fail to understand what exactly is causing the build to fail. Please enlighten me or give me some pointers as to where should I be looking at.

Keen to hear from you soon.

Regards,
Aijaz

Last edited by aijazbaig1; 07-04-2012 at 06:27 AM.
 
Old 07-05-2012, 12:48 AM   #2
aijazbaig1
LQ Newbie
 
Registered: Jun 2007
Location: Mumbai, India
Distribution: centos, opensuse
Posts: 15

Original Poster
Rep: Reputation: 0
Moderator, could you please delete this thread from here? It should have been posted under Linux-kernel and I've done that now.

Thanks again and sorry for the wrong address this time

Regards,
Aijaz Baig
 
Old 07-05-2012, 03:35 AM   #3
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
Try this

In the makefile for the module use the path to the kernel source along with make i.e.

Code:
obj−m += hello−1.o

all: 
make -C <Path to kernel source> M=$(shell pwd) modules

clean: 
make -C <Path to kernel source> M=$(shell pwd) clean
 
Old 07-05-2012, 04:41 AM   #4
aijazbaig1
LQ Newbie
 
Registered: Jun 2007
Location: Mumbai, India
Distribution: centos, opensuse
Posts: 15

Original Poster
Rep: Reputation: 0
Hello bsat

Could we continue the discussion here: http://www.linuxquestions.org/questi...el-4175414977/

Im going to ask the mod to close this one so more people interested in kernel development can take a look there.

Thanks
 
  


Closed Thread

Tags
autoconf, build, building, kernel



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
Fedora kernel / vanilla kernel compiling chipotphe Linux - Kernel 2 09-13-2008 01:06 PM
loadable kernel module compilation error for SHA1 functions nikhil86 Programming 1 03-25-2008 09:08 PM
Error compiling NVIDIA kernel module on 2.6.23.1 kernel Slaco Linux - Hardware 6 10-31-2007 07:57 PM
reboot kernel from kernel from loadable module ? jeff price Linux - Kernel 1 01-11-2007 05:22 AM
kernel version 2.4 loadable kernel module mhuman1 Linux - Kernel 2 05-11-2006 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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