0
votes

I am compiling (& linking) my Linux driver code and getting the following error while module linking. I tried to check my Makefile for any potential errors(tabs, spaces, etc). However, it's pretty much used for my other kernel module programming and it works fine. Any sort of poi

Module Src :

Makefile :

obj-m += static_waitqueue_driver.c

KDIR = /lib/modules/$(shell uname -r)/build

all: make -C $(KDIR) M=$(shell pwd) modules

clean: make -C $(KDIR) M=$(shell pwd) clean

Error :

User:sudhanshu Host:UbuntuVirtualBox Date:Wed Apr 01
Time:13:23:36 24 ~/tmp/01_linux_learning/10_wait_queue $ make make -C /lib/modules/5.3.0-28-generic/build M=/home/sudhanshu/tmp/01_linux_learning/10_wait_queue modules make[1]: Entering directory '/usr/src/linux-headers-5.3.0-28-generic'
Building modules, stage 2. scripts/Makefile.modpost:113: target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' doesn't match the target pattern scripts/Makefile.modpost:114: warning: overriding recipe for target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' scripts/Makefile.modpost:101: warning: ignoring old recipe for target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' scripts/Makefile.modpost:128: target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' doesn't match the target pattern scripts/Makefile.modpost:129: warning: overriding recipe for target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' scripts/Makefile.modpost:114: warning: ignoring old recipe for target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' MODPOST 1 modules LD [M] /home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c ld: no input files scripts/Makefile.modpost:129: recipe for target '/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c' failed make[2]: * [/home/sudhanshu/tmp/01_linux_learning/10_wait_queue/static_waitqueue_driver.c] Error 1 Makefile:1658: recipe for target 'modules' failed make[1]: * [modules] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-5.3.0-28-generic' Makefile:6: recipe for target 'all' failed make: *** [all] Error 2

1

1 Answers

0
votes

I fixed this error. I feel there was some invisible character or some missing "\n(newline char)" in Makefile that was creating the issue.

But when I created a new file and typed manually (earlier I had copy-pasted), then things worked.

Solution: Make sure you don't have any special (invisible) characters in your makefile.

Latest Makefile (copy paste from console) :

1 obj-m += static_waitqueue_driver.o 2 KDIR = /lib/modules/$(shell uname -r)/build 3 all: 4 make -C $(KDIR) M=$(shell pwd) modules 5 clean: 6 make -C $(KDIR) M=$(shell pwd) clean