免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2397 | 回复: 0
打印 上一主题 下一主题

[网络子系统] Makefile 内核模块 包含非内核头文件该如何修改? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-04-06 16:54 |显示全部楼层 |倒序浏览
小弟最近根据论坛里的方法编写了一个基于Netfilter 的hook 模块(checkIP.c)。
用的方法基本上是http://bbs.chinaunix.net/thread-1941060-1-1.html 白手起家 大神里面的方法。
但是我的方法略有不同,使用了linux 自带的 正则表达式方法(regex.h 文件在/usr/include 文件夹里面)
本人根据网上的各种说明写了一个Makefile 但是不能正常编译,
Makefile 编写如下:
obj-m :=checkIP.o
KERNELDIR := /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
modules:
        $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
        rm -rf *.o *~core .*.cmd *.mod.c ./tmp version


每次编译都会出现问题,不能正常编译。
问题如下:
make -C /lib/modules/4.4.0-67-generic/build M=/home/linhos/progect/c++/untitled/modul modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-67-generic'
  CC [M]  /home/linhos/progect/c++/untitled/modul/checkIP.o
/home/linhos/progect/c++/untitled/modul/checkIP.c:16:19: fatal error: regex.h: 没有那个文件或目录
compilation terminated.
scripts/Makefile.build:264: recipe for target '/home/linhos/progect/c++/untitled/modul/checkIP.o' failed
make[2]: *** [/home/linhos/progect/c++/untitled/modul/checkIP.o] Error 1
Makefile:1420: recipe for target '_module_/home/linhos/progect/c++/untitled/modul' failed
make[1]: *** [_module_/home/linhos/progect/c++/untitled/modul] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-67-generic'
Makefile:5: recipe for target 'modules' failed
make: *** [modules] Error 2



跪求各位大神,我的Makefile该怎么写?

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP