[vox-tech] Module build
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Sat Sep 3 08:05:58 PDT 2005
Richard Harke wrote:
> When building a kernel module, one needs to use the same header
> files as were used to build the kernel it will be loaded into. But all
> I ever file in the .c file is #include <llinux/whatever.h> Normally this
> should refer to /usr/include/linux but this is likely not to be
> right for a kernel module. On my system, if I want the current
> kernel header, it would be /usr/src/linux/include/linux
> Or it could be reached as /lib/modules/<version>/build/include/linux
>
> Can someone tell me just how the correct version is found
> when building kernel modules?
/usr/include/linux:
This holds the headers that were used for building the libraries on the
system... they are normally "behind" the actual kernel version, sometimes
by quite a lot.
Note that compiling kernel modules is a process that excludes userland
libraries... kernel code has to be internally self-sufficient... so it
is perfectly normal for kernel headers to use a superset of capabilities
beyond what userland programs use. Conversely, userland programs should
be compiled in a manner consistent with the userland libraries that they
will depend on, so using "up-to-date" headers for userland programs can
lead to inconsistencies when working with libraries (particularly libc).
/usr/src/linux/include/linux:
This used to be the "canonical" location for headers that were to be used
in compiling a linux kernel. This caused quite a bit of confusion, and
nowadays there should be no "canonical" location... you should be able
to compile your kernel in any directory you want to, so you can work on
multiple kernel versions without being root and changing systemwide
configurations, but depending on this directory prevented multiple
developers from working on kernel sources simultaneously on the same
machine.
/lib/modules/<version>/build/include/linux:
I hadn't noticed this directory before... but it makes sense as
corresponding to the kernel "<version>" that you are running, and
therefore being most appropriate for compiling a module to load in your
running kernel.
--
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
More information about the vox-tech
mailing list