-   Linux - Newbie (
-   -   Error compiling loadable kernel module with vanilla kernel (

aijazbaig1 07-04-2012 07:24 AM

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 and then I did a

menu xconfig
on it to create a .config file. After having done that, I run

on the top level directory which seems to work fine.


make modules
fails with the following errors:


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

make modules
and it seemed to have went fine (note that ive already installed the modules under /lib/modules/ by doing a

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:

obj−m += hello−1.o

make -C /lib/modules/ M=$(shell pwd) modules

make -C /lib/modules/ 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 '' 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

make all
in the directory where I have my kernel module source. However I get the following errors:

make -C /lib/modules/ M=/home/aijazbaig1/modules modules
make[1]: Entering directory `/home/aijazbaig1/linux-'
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; \
mkdir -p /home/aijazbaig1/modules/.tmp_versions ; rm -f /home/aijazbaig1/modules/.tmp_versions/*

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

make -f scripts/ obj=/home/aijazbaig1/modules
(cat /dev/null; ) > /home/aijazbaig1/modules/modules.order
make -f /home/aijazbaig1/linux-
scripts/mod/modpost -m -a -i /home/aijazbaig1/linux- -I /home/aijazbaig1/modules/Module.symvers -o /home/aijazbaig1/modules/Module.symvers -S -w -s
make[1]: Leaving directory `/home/aijazbaig1/linux-

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-]# find . -name autoconf.h
[root@MyCentOS-VM linux-]# find . -name 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.
[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-

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.


aijazbaig1 07-05-2012 01:48 AM

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 :)

Aijaz Baig

bsat 07-05-2012 04:35 AM

Try this

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


obj−m += hello−1.o

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

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

aijazbaig1 07-05-2012 05:41 AM

Hello bsat

Could we continue the discussion here:

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


All times are GMT -5. The time now is 09:27 PM.