모듈 프로그래밍 질문입니다.
글쓴이: 사욱환 / 작성시간: 일, 2005/09/11 - 11:26오전
간단한 모듈을 올려서 테스트 해보려고 하는데, 컴파일 에러가 나네요..
코드는 다음과 같구요,
/* hello_module.c */ #ifndef __KERNEL__ #define __KERNEL__ #endif #ifndef __MODULE__ #define __MODULE__ #endif #define __NO_VERSION__ #include <linux/kernel.h> #include <linux/module.h> int init_module(void) { printk("Hello Module!! I'm in Kernel\n"); return 0; } void cleanup_module(void) { printk("Bye Module!!\n"); }
다음과 같이 Makefile 만들어 컴파일 했습니다.
CC = gcc IDIR = /usr/include/ CFLAGS = -D__KERNEL__ -DMODULE -I$(IDIR) CFLAGS += -Wall -c TARGET = hello_module SRC = $(TARGET).c all: $(TARGET).o $(TARGET).o : $(CC) $(CFLAGS) $(SRC)
그런데 다음과 같은 에러가 나네요..
gcc -D__KERNEL__ -DMODULE -I/usr/include/ -Wall -c hello_module.c In file included from /usr/include/linux/module.h:10, from hello_module.c:12: /usr/include/linux/config.h:5:2: #error Incorrectly using glibc headers for a kernel module hello_module.c: In function `init_module': hello_module.c:15: warning: implicit declaration of function `printk'
컴파일 환경은 Fedora Core 2, linux-2.6.5-1.358 이구요,
리눅스 설치할 때 커널 컴파일 가능하도록 설치했습니다.
명쾌한 답변 부탁 드립니다.
Forums:
어느정도 해결된거 같네요..
아래 링크가 많은 도움 됐습니다.
http://www.tldp.org/LDP/lkmpg/2.6/html/index.html
..
댓글 달기