Problem in buliding a kernel module

Asked by Jagadeesh

Hi all ,
I'm trying to build a simple kernel module ..
But when running make command its giving error....

my module code is like this
*********************** MODULE.C**************************
#include<linux/module.h> //kmod interface
#include<linux/version.h>// kernel version stamp
#include<linux/kernel.h>// resolve kernel symbol calls
#include<linux/init.h>

void func(void);

int val=300;

void func()
{
        printk("func invoked\n ");
        printk(" val = %d",val);
}

int init_mod(void)
{
        printk("module inserted\n ");
        return 0;
}

void cleanup_mod(void)
{
        printk("module removed\n ");
}

module_init(init_mod);
module_exit(cleanup_mod);

/*Kernel module Comments*/
MODULE_AUTHOR("TEAM VEDA");
MODULE_DESCRIPTION("FIRST MODULE");
MODULE_LICENSE("GPL");
***********************************************************

***********************MAKEFILE***************************
obj-m =mod.o

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

all:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
         rm -rf $(wildcard *.o *.ko *.mod.* .c* .t* test Module.symvers *.order *.markers)

***********************************************************

after building , response is
************************************************************
root@ubuntu:/home/jag/Desktop/linux books/Ker-prog/kern-prog/modules# make
make -C /lib/modules/3.0.0-12-generic/build SUBDIRS=/home/jag/Desktop/linux books/Ker-prog/kern-prog/modules modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-12-generic'
make[1]: *** No rule to make target `books/Ker-prog/kern-prog/modules'. Stop.
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-12-generic'
make: *** [all] Error 2
 ***********************************************************

help me to solve this issuse

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu linux Edit question
Assignee:
No assignee Edit question
Solved by:
Colin Ian King
Solved:
Last query:
Last reply:
Revision history for this message
Best Colin Ian King (colin-king) said :
#1

Rename the "linux books" part of your path, the space in it is probably the problem.

e.g. rename /home/jag/Desktop/linux books/Ker-prog/kern-prog/modules to /home/jag/Desktop/linux-books/Ker-prog/kern-prog/modules

Revision history for this message
Jagadeesh (v-jagadeesh89) said :
#2

ohhh ya ... it's working.....
thank you king... this problem is solved..

Can I know what is the problem with the space in folder name....??????