简体   繁体   中英

Running the Linux Kernel Module ( Hello World )

I am trying to run a hello world kernel module but its showing module.h is no present. but i have module.h in /usr/src/linux.2.xx.xx/includes/.Please help me how to set this path?

Try the following in your shell in the directory with the source of your module:

export KDIR=/usr/src/linux.2.xx.xx
make -C $KDIR M=`pwd`

That header should be used via #include <linux/module.h>

try to touch a new makefile which coding like below

ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
  1. this makefile should name "Makefile"
  2. put it in the same directory with the hello.c file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM