Getting error while compiling my first kernel module in Fedora linux.
Source code :--
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
Makefile :----
obj-m = hello.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
error at make time :--
$ make
make -C /lib/modules/3.8.6-203.fc18.x86_64/build M=/home/dinesh/development/linux/kernel_modules/hello modules
make: *** /lib/modules/3.8.6-203.fc18.x86_64/build: No such file or directory. Stop.
make: *** [default] Error 2
Now if i see build is there or not , i get following o/p. Build is shown as an softlink :---
$ ls -l /lib/modules/3.8.6-203.fc18.x86_64/
total 2632
lrwxrwxrwx. 1 root root 38 Apr 15 21:32 build -> /usr/src/kernels/3.8.6-203.fc18.x86_64
drwxr-xr-x.
I got same error even after installing, kernel-devel :--
My makefile is correct it have correct tab before rule. Please suggest how to resolve this error ?
As guido said, you have to match your current kernel and the kernel-devel package.
To get your kernel version run
uname -r
I get 3.6.10-4.fc18.x86_64, download that kernel-devel version
sudo yum install kernel-devel-3.6.10-4.fc18
Or update your system and boot with the new kernel, I believe those two will automatically match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With