PDA

View Full Version : problem with building kernel modules



samsneelam
31st July 2008, 07:40 AM
hi .. this is samuel,
Here i had a problem while building kernel modules and then compiling, I got Linux kernel module programming guid, i am practising that book to make use for one of task. But as i am trying i m getting the following proble,..

Here is my hello1.c program
----------------------------------------------------------------------------------------------------------------------------
/*
* hello−1.c − The simplest kernel module.
*/
# include <linux/module.h> /* Needed by all modules */
# include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
------------------------------------------------------------------------------------------------------------------

and here is the make file for that....
-----------------------------------------------------------------------------------------------------------------

obj-m +=hello1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
--------------------------------------------------------------------------------------------------------------

but when i make the program, i am getting the following message...


[root@samuel HelloWorld]# make
make -C /lib/modules/2.6.18-1.2798.fc6/build M=/root/MPCP-Total Info/freshCodeMPCP/HelloWorld modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-1.2798.fc6-i586'
make[1]: *** No rule to make target `Info/freshCodeMPCP/HelloWorld'. Stop.
make[1]: Leaving directory `/usr/src/kernels/2.6.18-1.2798.fc6-i586'
make: *** [all] Error 2

.....................................

CAN anybody help to get rid of this...
Thanks in advance

JohnVV
31st July 2008, 08:12 AM
just a guess but try it with out the -C option
-C DIRECTORY, --directory=DIRECTORY " Change to DIRECTORY before doing anything."

samsneelam
31st July 2008, 08:30 AM
just a guess but try it with out the -C option
-C DIRECTORY, --directory=DIRECTORY " Change to DIRECTORY before doing anything."
----------------------------------------------------------------------------------------------------------------------------

I tried .. but i am gettting the following information

--------------------------------------------------------------------
make /lib/modules/2.6.18-1.2798.fc6/build SUBDIRS=/root/MPCP-Total Info/freshCodeMPCP/HelloWorld2 modules
make[1]: Entering directory `/root/MPCP-Total Info/freshCodeMPCP/HelloWorld2'
make[1]: Nothing to be done for `/lib/modules/2.6.18-1.2798.fc6/build'.
make[1]: *** No rule to make target `Info/freshCodeMPCP/HelloWorld2'. Stop.
make[1]: Leaving directory `/root/MPCP-Total Info/freshCodeMPCP/HelloWorld2'
make: *** [default] Error 2
-------------------------------------------------------------------------------------------------

markkuk
31st July 2008, 10:15 AM
[root@samuel HelloWorld]# make
make -C /lib/modules/2.6.18-1.2798.fc6/build M=/root/MPCP-Total Info/freshCodeMPCP/HelloWorld modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-1.2798.fc6-i586'
make[1]: *** No rule to make target `Info/freshCodeMPCP/HelloWorld'. Stop.

You have a space in your directory name which causes make to think that "M=/root/MPCP-Total" and "Info/freshCodeMPCP" are two separate parameters. Change the name to remove any spaces.

JohnVV
31st July 2008, 04:36 PM
how about running the command


make all

samsneelam
1st August 2008, 05:57 AM
HI mark,,..
Thank you, It worked with ur technique...

THANK YOU FRIENDS FOR UR HELP....