[질문] Module Programming 공부하는 초보입니다.
[root@NARAPING modulePrograms]# make
gcc -O2 -DMODULE -D__KERNEL__-W -Wall -Wstrict-prototypes -Wmissing-prototypes-i
system /lib/modules/`uname -r`/build/include -c -o hello-1.o hello-1.c
gcc: cannot specify -o with -c or -S and multiple compilations
make: *** [hello-1.o] 오류 1
Linux Kernel Module Programming Guide에 있는 첫번재 소스입니다.
그런데 똑같이 코딩을 한거 같은데 오류가 나서 어떤게 틀렸는지, 혹시나 환경설정을 해줘야 하는지 가르쳐주시면 감사하겠습니다.
아래의 소스 코드를 Makefile을 이용하여 make하면 위와 같은 오류가 납니다.
어떻게 해결해야할지 방법좀 가르쳐주세요.
---------------------------------------------------------------------------------
hello-1.c
---------------------------------------------------------------------------------
#include <linux/module.h> //모든 모듈에 필요 #include <linux/kernel.h> //kern_alert에 필요 int init_module(void) { printk("<1> Hello World. \n"); return 0; } void cleanup_module(void) { printk(KERN_ALERT "Goodbye world \n"); }---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
Makefile
---------------------------------------------------------------------------------
TARGET := hello-1 WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes INCLUDE := -isystem /lib/modules/'uname -r'/build/include CFLAGS := -O2 -DMODULE -D__KERNEL__${WARN}${INCLUDE} CC := gcc ${TARGET}.o:${TARGET}.c .PHONY: clean clean: rm -rf {TARGET}.o
---------------------------------------------------------------------------------
Wmissing-prototypes 과 -isystem 사이에 한 칸 띄
Wmissing-prototypes 과 -isystem 사이에 한 칸 띄우셔야죠. Makefile 에서 ${INCLUDE} 앞에 한 칸 띄우셔야겠네요. :-)
좋은 하루 되세요!
Re: [질문] Module Programming 공부하는 초보입니다.
CFLAGS := -O2 -DMODULE -D__KERNEL__${WARN}${INCLUDE}
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
오류 메세지만 잘 봐도 쉽게 잡아내지요.
(엇 올리고 나니 이미 답이 ^^;)
ㄲ ㅏ ㅂ ㅣ / M c K a b i / 7 7 r b i / T o D y
댓글 달기