如何导出修改后的内核头文件 [英] how to export a modified kernel header

查看:161
本文介绍了如何导出修改后的内核头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux内核中修改了一些文件

I modified some files in the Linux kernel

include/linux/tcp.h
include/net/tcp.h 
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp_output.c

在此之后,我编译了修改后的Linux内核

Following this i compiled the modified Linux kernel

$ make modules_install  
$ make headers_install INSTALL_HDR_PATH=/usr/include  
$ make install  

新内核可以启动,一切似乎都很正常.但是,当我尝试在应用程序中包含修改后的内核头文件时,编译器抱怨该头文件未定义我刚刚添加的类型.检查/usr/include/netinet/tcp.h后,我发现它不是我修改的文件.

The new kernel can start, everything seems normal. But when i tried to include the modified kernel header in my app, the compiler complains that the header does NOT define the types which i have just added. Upon checking /usr/include/netinet/tcp.h, i find that it is NOT the file i modified.

我如何正确导出修改后的Linux内核标头以包含在C程序中?

推荐答案

在更改某些Linux标头时,请先执行make命令以查看是否有任何副作用.内核可能无法编译.这是绝对必要的.

As you are changing some linux header, do a make first to see whether there are any side effects. The kernel might not compile. This is absolutely necessary.

我认为make对于使内核标头生效的更改也是必要的,以便可以将其导出到用户空间.

I think make is also necessary for the changes to take effect for the kernel headers so that they can be exported to user space.

只需执行make modules_install即可安装已构建的模块,不会针对更改后的头重新编译这些模块.对于其他安装命令也是如此.

Just doing make modules_install will install already built modules, the modules won't be recompiled against the changed headers. Similarly for other install commands.

这篇关于如何导出修改后的内核头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆