which kernel headers where

Bryan Kadzban bryan at kadzban.is-a-geek.net
Mon Jan 12 04:05:47 PST 2004

Ryan.Oliver at pha.com.au wrote:
> Because you copied them there. Unless you specify CPPFLAGS of 
> -I/usr/src/linux/include (and you don't want to do that)

By way of explanation,  since the compiler is looking for linux/cdrom.h
(for example), it will find it at /usr/include/linux/cdrom.h.  Which is
as it should be -- programs from userspace (except glibc) need the
linux/cdrom.h that glibc has features from (except in the case of 2.6
headers; then they just need something that's mostly from 2.4, i.e.
sanitized headers).  That's not /usr/src/linux/include/linux/cdrom.h in
any setup.

> the compiler will never look in the kernel tree for headers, only
> /usr/local/include 
> ${prefix}/lib/gcc-lib/${target}/${gcc_version}/include (gcc's includes)
> ${prefix}/${target}/include (where you'd stick target
> system headers if cross-compiling)
> and /usr/include

Again for a bit more explanation, he arguments to -I get put at the
*top* of this list of directories to search.  So if you specify
-I/usr/src/linux/include, then gcc will find linux/cdrom.h there, and
stuff can break.

(If -I's got put at the end, for example, then /usr/src/linux/include
would never get searched, because the compiler would always find
/usr/include/whatever first.  But that would probably break other
things, like kernel modules.)

More information about the lfs-dev mailing list