xiao su
xiao su

Reputation: 167

how to export a modified kernel header

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

Following this i compiled the modified Linux kernel

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

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.

Q. How can i properly export modified Linux kernel headers to include in a C program ?

Upvotes: 3

Views: 1382

Answers (3)

The right location of INSTALL_HDR_PATH should be /usr instead:

$ make headers_install INSTALL_HDR_PATH=/usr

Upvotes: 0

Vivek S
Vivek S

Reputation: 1261

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.

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.

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.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798636

A. Copy them to somewhere the code expects to find them, such as a directory you then pass to the compiler via -I, and then make sure that the code actually includes them.

Upvotes: 1

Related Questions