开发者

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/includ开发者_如何学Pythones/.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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜