-   Linux - Kernel (
-   -   module compilation problem (

ktnamus 12-04-2012 06:46 AM

module compilation problem
i am using ubuntu 12.04 with linux
i tried to compile mymodule.c
using make command.suggest me for the error occurred as below:

root@ubuntu:~# cd m
module/ mymodule.c
root@ubuntu:~# cp mymodule.c /root/module/
root@ubuntu:~# cd module/
root@ubuntu:~/module# ls
root@ubuntu:~/module# gedit mymodule.c
root@ubuntu:~/module# gedit makefile
root@ubuntu:~/module# make
make -C /lib/modules/3.2.0-23-generic/build M=/root/module modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-23-generic'
scripts/ /root/module/Makefile: No such file or directory
make[2]: *** No rule to make target `/root/module/Makefile'. Stop.
make[1]: *** [_module_/root/module] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-23-generic'
make: *** [all] Error 2

knudfl 12-04-2012 08:13 AM

Welcome to LQ.

Looks like you have no Makefile.
The Makefile must be in the same folder as mymodule.c

A Makefile that works :

obj-m    := mymodule.o

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

        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

ktnamus 12-05-2012 09:38 PM

i copied makefile as you given. it gives same error like this:-
make -C /lib/modules/3.2.0-23-generic/build SUBDIRS= modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-23-generic'
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[2]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.s'. Stop.
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-23-generic'
make: *** [default] Error 2

knudfl 12-06-2012 03:21 AM

# 3 . Suggest : Install the package 'linux-source-3.2.0'.

Instead of setting up the source to build against,
you could try with a copy of bounds.c from
/usr/src/linux-source-3.2.0/linux-source-3.2.0.tar.bz2 :

sudo cp bounds.c /usr/src/linux-headers-3.2.0-23-generic/kernels/

ktnamus 12-07-2012 11:45 PM

but it is not for only bound.c, it is also showing this msg for other files.
and so, what is the difference remains between source and header files?

knudfl 12-08-2012 04:19 AM

# 5 : The package 'linux-headers-* ' : Provides files.h only.

And 'linux-source-3.2.0' : The full kernel source code,
i.e. files.h, files.c .

posix04 12-09-2012 04:53 AM

Install the build-essential metapackage too.

All times are GMT -5. The time now is 10:26 PM.