Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I tried to compile my first loadable kernel module and failed :(

Here is the error:

r@ubuntu:/$ sudo make -C /lib/modules/`uname -r`/build/ M=`pwd`
[sudo] password for r: 
make: Entering directory `/usr/src/linux-headers-2.6.38-8-generic'
scripts/Makefile.build:76: kbuild: Makefile.build is included improperly
make[1]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.s'.  Stop.
make: *** [_module_] Error 2
make: Leaving directory `/usr/src/linux-headers-2.6.38-8-generic'

I need help knowing what is wrong.

Here is the makefile i am using:

obj-m += sample_module_for_techblog.o 
     make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules 
     make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean 
clean-files := Module.symvers

i found out the following piece of code (which is printing the piece of error that i ma getting) from here

ifndef obj
$(warning kbuild: Makefile.build is included improperly)

i hope this helps solve the issue.

share|improve this question

migrated from stackoverflow.com Jan 4 '12 at 18:21

This question came from our site for professional and enthusiast programmers.

Given that I have a file named /usr/src/linux- on my system, I would suspect that on your system a file named /usr/src/linux-headers-2.6.38-8-generic/kernel/bounds.c is missing, for whatever reason. –  PlasmaHH Jan 4 '12 at 17:21
It doesn't come with it - I just checked (for the 37-generic sub number I'm running). I only got the assembly file bounds.s. If I had to guess, this file (these files) are used by the kernel makefile we're accessing. The problem though is almost certainly an issue with the makefile the user is providing, so drunkM: could you please add the makefile you're using? –  gnometorule Jan 4 '12 at 18:01
@gnometorule i have added the makefile ... –  Wildling Jan 4 '12 at 18:03
@gnometorule there was no change in the error after i did what you suggested in your answer .. –  Wildling Jan 4 '12 at 18:33

1 Answer 1

up vote 1 down vote accepted

Try this one, adjusted as necessary. I'm not familiar with the tutorial you link in, but assume you created the most basic 'hello world' style module that you try to compile:


    KERNELDIR ?= /lib/modules/$(shell uname -r)/build
    PWD := $(shell pwd)

        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules

        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

# adjust this by removing what applies to you
        rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions \
        *.symvers  *.order 

.PHONY: modules modules_install clean

obj-m := hello.o 

share|improve this answer
i'll try this .. in the meantime pls go though the part of the question i just edited .. –  Wildling Jan 4 '12 at 18:43
still the same error i got –  Wildling Jan 4 '12 at 18:45
Create a simple 'hello world' module (per this model, if it differs from yours: lwn.net/Articles/21817. Please add a line including <linux/init.h> as well), then run this with the code I added above - careful that you obviously adjust for the file names etc that you build. You are digging into inclusions and further steps performed by the kernel level module makefile, which you shouldn't have to. So something is strange, and I'd start by testing something that definitely runs - at least on my Ubuntu distro. There might be slight differences between distros, but not too severely. –  gnometorule Jan 4 '12 at 19:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.