3
votes

I am new to kernel module development. So I started with simple hello world kernel module I am using "The Linux Kernel Module Programming Guide" book for the reference (it is addressing to kernel 2.6). I installed kernel-devel and kenel headers with yum. I am using fedora 17. I found that a symlink

/lib/modules/3.3.4-5.fc17.x86_64/build -> /usr/src/kernels/3.3.4-5.fc17.x86_64

Now, I have one hello-1.c (the simple kernel module and a Makefile in my working directory) The Makefile is:

obj-m += hello-1.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

when in $make i get error:

make -C /lib/modules/3.3.4-5.fc17.x86_64/build M=/root/kerneldev modules
make: *** /lib/modules/3.3.4-5.fc17.x86_64/build: No such file or directory.  Stop.
make: *** [all] Error 2

I make same program on Centos-5.x it run successfully , because the /lib/modules/3.3.4-5.fc17.x86_64/build was containing the actual module (not a symlink). What should be problem ? why such difference?

3
I'm also using fedora 17/18 with the same symlink and I don't have any problem.. It is a valid symlink? /usr/src/kernels/3.3.4-5.fc17.x86_64 exists ? - Federico

3 Answers

0
votes

I have few doubts like, where your issuing the make command. Your current directory seems to be

M=/root/kerneldev

whether your hello-1.c is in /root/kerneldev folder.

0
votes

try "yum install kernel-devel"(for kernel headers)

0
votes

The message

make: *** /lib/modules/3.3.4-5.fc17.x86_64/build: No such file or directory.  Stop.

Is telling you that the directory path after the *** does not exist. Make issues this exact format of error when the -C directory doesn't exist. Other non-existent path situations will result in more words. For example, if the /lib/modules/3.3.4-5.fc17.x86_64/build directory does exist but it contains no makefile, make will specifically say no makefile found.

So the other answers are giving you ideas to help you create that directory with its proper contents.

And this answer is intended to also help people who have the above form of error message and for whom installing 'kernel-devel' will not help, by explaining the message itself.