更新时间:2023-10-15 16:06:22
Makefile
Makefile
obj-m:= hello.o#模块名称是hello.c
obj-m := hello.o # Module Name is hello.c
KDIR:=/lib/modules/$(shell uname -r)/build
KDIR := /lib/modules/$(shell uname -r)/build
全部:$(MAKE)-C $(KDIR)M = $(PWD)个模块
all: $(MAKE) -C $(KDIR) M=$(PWD) modules
clean:$(MAKE)-C $(KDIR)M = $(PWD)clean $(RM)Module.markers modules.order
clean: $(MAKE) -C $(KDIR) M=$(PWD) clean $(RM) Module.markers modules.order
不能保证头文件始终位于/usr/src目录中,但可以肯定地位于/lib/modules目录中.
its not guaranteed that headers file will always be located in /usr/src directory, but it will surely be located in /lib/modules directory.
找出要显示的头文件 运行`
to find out which header files to be present run `
uname -r
uname -r
在终端上,输出将类似于
on terminal, output will be like
3.5.0-17-generic
运行安装头文件
sudo apt-get install linux-headers-$(uname -r)