Linux Kernel Module compile 시 "No rule to make target `modules'"
IT,PC,모바일,스마트폰 정보와 팁 그리고 제품리뷰와 생활정보
Linux Kernel Module compile 시 "No rule to make target `modules'"
2012. 3. 7. 14:11
kernel module compile 하다가 아래 "No rule to make target 'modules' 가 발생해서 1주일을 고민 했네요..
하지만 다른 문제가 아니래 제 실수 였습니다..
Error
Makefile
hello.c
문제는 Makefile 이였습니다..
make -C /lib/modules/$(shell uname -r)/build/include M=$(PWD) modules
에서 include 를 뺐어야 했네요.. ^^
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
이렇게 하고 나서 잘 됩니다.
하지만 다른 문제가 아니래 제 실수 였습니다..
Error
root@heoming-virtual-machine:~/hello# make
make -C /lib/modules/3.0.0-16-generic/build/include M=/root/hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-16-generic/include'
make[1]: *** No rule to make target `modules'. Stop.
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-16-generic/include'
make: *** [default] Error 2
make -C /lib/modules/3.0.0-16-generic/build/include M=/root/hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-16-generic/include'
make[1]: *** No rule to make target `modules'. Stop.
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-16-generic/include'
make: *** [default] Error 2
Makefile
obj-m += hello.o
KDIR := /lib/modules/3.0.0-16-generic/build
PWD := $(shell pwd)
default:
make -C /lib/modules/$(shell uname -r)/build/include M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build/include M=$(PWD) clean
KDIR := /lib/modules/3.0.0-16-generic/build
PWD := $(shell pwd)
default:
make -C /lib/modules/$(shell uname -r)/build/include M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build/include M=$(PWD) clean
hello.c
#include
<linux/module.h>
#include
<linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "init_module() called\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "cleanup_module() called\n");
}
<linux/module.h>
#include
<linux/kernel.h>
int init_module(void)
{
printk(KERN_INFO "init_module() called\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "cleanup_module() called\n");
}
문제는 Makefile 이였습니다..
make -C /lib/modules/$(shell uname -r)/build/include M=$(PWD) modules
에서 include 를 뺐어야 했네요.. ^^
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
이렇게 하고 나서 잘 됩니다.
root@heoming-virtual-machine:~/hello# make
make -C /lib/modules/3.0.0-16-generic/build M=/root/hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-16-generic'
CC [M] /root/hello/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/hello/hello.mod.o
LD [M] /root/hello/hello.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-16-generic'
make -C /lib/modules/3.0.0-16-generic/build M=/root/hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-16-generic'
CC [M] /root/hello/hello.o
Building modules, stage 2.
MODPOST 1 modules
CC /root/hello/hello.mod.o
LD [M] /root/hello/hello.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-16-generic'
Skin By KEBIBLOG Ver 1.0 Copyright ⓒ KEBI BLOG. All rights reserved.