Results 1 to 7 of 7
Hi Everyone,
This is the hello world kernel module:
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world\n");
}
and ...
- 01-25-2010 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 5
Hello world Module
Hi Everyone,
This is the hello world kernel module:
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "Hello world.\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world\n");
}
and this is the make file
obj-m += hello.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
At the command prompt i type make and this is what I am getting:
make -C /lib/modues/2.6.24-16-generic/build M=/home/louisemodules
make[1]: Entering directory 'usr/src/linux-headers-2.6.24-16-generic
make: *** [all] Error 2
mkdir: cannot create directory home/louisemodules: permission denied
scripts /Makefile.build:41: home/louisemodules/Makefile: No such file or
directory
make[2]: *** No rule to make target /home/louisemodules/Makefile. Stop
make[1]:***[_module_/home/louisemodules] Error 2
make[1]: Leaving directory /usr/src/linux-headers-2.6.24-16-generic
make: *** [all] Error 2
Please help me,
Thanks
- 01-25-2010 #2
Did you install the kernel-header and kernel-devel files?
Make mine Arch Linux
- 01-25-2010 #3Just Joined!
- Join Date
- Dec 2009
- Posts
- 5
Did you install the kernel-header and kernel-devel files?
Hi there,
Thanks for getting back to me. I know that I have the header files, is there a command that I can type to check for deval files? Looking at the output when I run make, it seems to be opening the header files, but seems to have a problem making the directory for the module.
Thanks
- 01-25-2010 #4
Try logging in as root
Make mine Arch Linux
- 01-26-2010 #5Just Joined!
- Join Date
- Dec 2009
- Posts
- 5
Hi Gerard,
I tried that, but I am still getting the same error message. Have you any other suggestions?
Thanks
- 01-26-2010 #6
The only other thing I can think of...Is your Makefile formatted correctly
where each make line is <TAB> inCode:obj-m += hello.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
Make mine Arch Linux
- 01-26-2010 #7Just Joined!
- Join Date
- Jul 2009
- Posts
- 49
kernel module compile problems...
I tried your code on my machine here. I ran into an issue with where your make file is expecting to find your kernel source. This pointed out to me that we really need to know which distro you are compiling on. I use openSuSE which really used the /lib/module/`uname -r`/source directory rather than the /lib/module/`uname -r`/build directory. This is easily fixed with a symbolic link (which did exist but was pointing to the wrong place.. better go annoy the openSuSE people about that!).
So, which distro are you compiling on?
Cheers!!


Reply With Quote
