Issue
I am trying to write a very basic "Hello World" device driver example which is taught in any device driver implementation introductory course. My makefile is as follows:
obj-m := hello.o
KDIR := /lib/modules/$(shell uname -r)/bulid
PWD := $(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
When I am using the make command, it is showing that /lib/modules/version_no/build/ is not existent. So I entered the directory /lib/modules/version_no and found that there is one directory build but if I use the ls command, it is printed in red colour, which means that the directory is deprecated. It contains one link to ../../../usr/src/version_no, but to my surprise, the version number in that link and the name of the actual folder in /usr/src/ are not same. Can anyone point out what is the issue? I am using centos 6.1.
Solution
This is because you have not yet downloaded the linux headers of your particular kernel version.
Assuming your kernel version is 4.15.0-32-generic
, install the required header files using sudo apt install linux-headers-4.15.0-32-generic
In your case you can get it by
yum install kernel-devel kernel-headers
Answered By - yashC Answer Checked By - Pedro (WPSolving Volunteer)