Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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).

share|improve this answer
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 May 17 '13 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 May 17 '13 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 May 17 '13 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! – Aleksandr Blekh Jan 2 at 8:12
@AleksandrBlekh Have you tried cat /proc/version after starting that version (e.g. in a VM)? – Anthon Jan 2 at 9:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.