I am compiling kernel 3.4 and 3.8 for different target devices. I would like to install compat wireless driver which requires kernel header. Could anyone tell me how I can compile/build the kernel header from the kernel source? I would appreciate if someone could suggest me a clear document to read or explain clearly how I can accomplish it.

Secondly, the target devices run Debian. would it work if I install the kernel header by apt-get install linux-headers-$(uname -r) for the device that would have 3.4 kernel? Or there might be conflict or problem?

1 Answer 1


It has been a while since I did cross compilation, but I found this description of doing cross compilation quite clear, YMMV.

Depending on your specific target there might be more specific documentation available online.

I would set up two complete new trees (one for 3.4 and one for 3.8) for compiling the kernel and not use the apt-get command as it will not install these headers in the new trees. Any changes you would make in files installed with apt-get would run the risk of breaking some other package relying on them (you obviously don't use any of those now, but you might in the future).

  • thank you for the reply. I am able to cross-compile and load the kernel. I was asking how to build the kernel headers (similar files that I get through apt-get install linux-headers-$(uname -r) ) . I could not see that info on the link you posted.
    – sven
    Commented May 17, 2013 at 9:41
  • @sven I am not sure if I understand your problem. If you download the kernel sources, the headers are included. Or are you talking about special headers that would be included in your (host) Debian install that are not in the sources?
    – Anthon
    Commented May 17, 2013 at 9:55
  • I need to create files under /lib/modules/3.4.0/build, as I read they are called kernel header or source files. what apt-get install linux-headers-$(uname -r) installs the source files under build directory. I wonder how I need to create the files under /lib/modules/3.4.0/build
    – sven
    Commented May 17, 2013 at 10:27
  • Anthon, I ran across your answer by trying to come up with my own solution to this problem. I'm wondering, if you could advise me on how to determine version of gcc, used to build a specific kernel, if it's not currently loaded, but I have access to the following files: openvz.org/Download/kernel/rhel6/042stab112.15. Thank you for reading this and Happy New Year! Commented Jan 2, 2016 at 8:12
  • @AleksandrBlekh Have you tried cat /proc/version after starting that version (e.g. in a VM)?
    – Anthon
    Commented Jan 2, 2016 at 9:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .