커널 모듈 생성

커널 모듈 생성

저는 현재 Linux 커널 모듈 프로그래밍에 관한 책을 읽고 있습니다.https://tldp.org/LDP/lkmpg/2.4/lkmpg.pdfmake를 실행할 때 컴파일 오류가 발생합니다.

/*  hello.c − The simplest kernel module.
 *
 */
/* Kernel Programming */

#define MODULE
#define LINUX
#define __KERNEL__

#include <linux/module.h>  /* Needed by all modules */
#include <linux/kernel.h>  /* Needed for KERN_ALERT */

int init_module(void)
{
   printk("<1>Hello world 1.\n");
   // A non 0 return means init_module failed; module can't be loaded.
   return 0;
}

void cleanup_module(void)
{
  printk(KERN_ALERT "Goodbye world 1.\n");
}

MODULE_LICENSE("GPL");
TARGET  := hello
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
gcc −O2 −DMODULE −D__KERNEL__ −W −Wall −Wstrict−prototypes −Wmissing−prototypes −isystem /lib/modules/`uname −r` /build/include   -c -o hello.o hello.c
uname: extra operand ‘−r’
Try 'uname --help' for more information.
gcc: error: −O2: No such file or directory
gcc: error: −DMODULE: No such file or directory
gcc: error: −D__KERNEL__: No such file or directory
gcc: error: −W: No such file or directory
gcc: error: −Wall: No such file or directory
gcc: error: −Wstrict−prototypes: No such file or directory
gcc: error: −Wmissing−prototypes: No such file or directory
gcc: error: −isystem: No such file or directory
gcc: error: /build/include: No such file or directory
make: *** [<builtin>: hello.o] Error 1

내가 받고 있는 오류는 Makefile에 정의된 명령 옵션입니다. 내가 이해하지 못하는 것은 무엇입니까?

답변1

-대시가 아닌 하이픈을 사용해야 합니다 .

불필요한 공간도 제거해야 합니다.

INCLUDE := -isystem /lib/modules/`uname -r`/build/include

(직전 /build/include).

관련 정보