l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2005 Sep 03 09:24

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Module build
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Module build



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@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
---------------------------------------------------------------------------
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.