Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am wondering what are kernel headers, and a kernel source tree exactly> Is the source tree the same as just a regular kernel source? Also, if one wanted to compile a kernel or add a module to a kernel, one usually needs the kernel source, but with the kernel headers do?
The kernel headers are the C language .h files relevant to the kernel, i.e. those used to build the kernel and those used when compiling programs (or more likely, drivers) that use aspects of the kernel. They are NOT enough to build a new kernel. For that you will need the kernel source (which is the same as the source tree) as this contains not only the headers, but the actual C source files containing the code used to compile into a kernel.
If you want a completely up to date kernel then kernel.org is the place to go. If your distro heavily patches their kernel then you might just want to use their source which is usually available on the install CD.
If you want a completely up to date kernel then kernel.org is the place to go. If your distro heavily patches their kernel then you might just want to use their source which is usually available on the install CD.
Yeah if you need the kernel source to install a driver then you must get it from your distro's package management system, just getting a vanilla kernel from kernel.org will not match your running kernel.
The kernel headers should be the ones in /usr/src/linux-*/include
Some glibc packages (specially rpm ones) install linux headers in /usr/include/linux in a very improper way that could cause problems if you install +1 kernels, worse if one is 2.4 and another 2.6
So the correct way would be to use uname(1) and use
/usr/src/linux-`uname -r`/include instead of <linux/version.h>
These days, some RPM distributions have a script named kheader that just solves this problem for /usr/src/linux/include/version.h and autoconf.h
The proper way would be to handle the linux symlink in /usr/src and /usr/include/linux entirely
hi, can anyone point me to a howto where it shows how to make a kernel headers package??
i wanna recompile my kernel and stuff, but IIRC the nvidia installer will complian if the headers you have at compile time aren't the same version of your current kernel (which is kinda odd, no?)...
so i would like to make a new kernel-headers package when i recompile the kernel (using the latest 2.4 prepatch), then i would recompile glibc with the new headers, and then i would do the nvidia install, etc...
i've made a kernel headers package before but i seem to have forgotten how it's done...
after looking at the contents of the official slackware kernel-headers i'm starting to think it's just a matter of packaging the contents of $SRC/include/linux and $SRC/include/asm-i386 (to /usr/include), where $SRC is the source code you just compiled your kernel with...
Just copy /usr/src/linux-$VERSION/include/{linux,asm-i386} $PKG/usr/include
ln -sf $PKG/usr/include/asm-i386 $PKG/usr/include/asm
That's pretty much it...
Code:
#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-kernel-headers
# If your using 2.4.32-rc1 as stated, what's that make our PKGVER? :-)
# Not such a hot idea IMO....
VERSION=2.4.31
PATCHVER=2.4.32-rc1
PKGVER=2.4.32_rc1
ARCH=i386
BUILD=1
rm -rf $PKG
mkdir -p $PKG/usr/include
cd $TMP
rm -rf linux-$VERSION
tar xjf $CWD/linux-$VERSION.tar.bz2
cd linux-$VERSION
bzip2 -dc $CWD/patch-$PATCHVER.bz2 | patch -p1
cp -R include/asm-$ARCH $PKG/usr/include/asm-$ARCH
cp -R include/linux $PKG/usr/include
( cd $PKG
chown -R root.root .
find usr/include/{asm-$ARCH,linux} -type d -exec chmod 755 {} \;
find usr/include/{asm-$ARCH,linux} -type f -exec chmod 644 {} \; )
( cd $PKG/usr/include
ln -sf asm-$ARCH asm )
mkdir -p $PKG/install
cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
kernel-headers: kernel-headers (Linux kernel include files)
kernel-headers:
kernel-headers: These are the include files from the Linux kernel.
kernel-headers:
kernel-headers: You'll need these to compile most system software for Linux.
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
EOF
# Build the package:
cd $PKG
makepkg -l y -c n $TMP/kernel-headers-$PKGVER-$ARCH-$BUILD.tgz
Originally posted by win32sux hi, can anyone point me to a howto where it shows how to make a kernel headers package??
i wanna recompile my kernel and stuff, but IIRC the nvidia installer will complian if the headers you have at compile time aren't the same version of your current kernel (which is kinda odd, no?)...
so i would like to make a new kernel-headers package when i recompile the kernel (using the latest 2.4 prepatch), then i would recompile glibc with the new headers, and then i would do the nvidia install, etc...
i've made a kernel headers package before but i seem to have forgotten how it's done...
any pointers would be greatly appreciated...
thanks...
OK, there seems to be some confusion. The kernel source in /usr/src/linux should match the currently running kernel or the nvidia installer will complain. The kernel headers in /usr/include/linux should match the kernel version that glibc was compiled against.
Originally posted by Komakino OK, there seems to be some confusion. The kernel source in /usr/src/linux should match the currently running kernel or the nvidia installer will complain. The kernel headers in /usr/include/linux should match the kernel version that glibc was compiled against.
Exactally.
Actually, the nvidia driver looks at /lib/modules/$(uname -r)/build and not /usr/src/linux... But yea, same idea.
I was wondering myself why you want to upgrade kernel-headers before a new glibc compile when the existing headers on slack are not even a version number away. Doesn't seem to be a point in it. If the 2.4.32-rc1 patch doesn't touch the header files, then you would be replacing the stock slack header package with an exact duplicate.... :-)
Originally posted by jong357 Just copy /usr/src/linux-$VERSION/include/{linux,asm-i386} $PKG/usr/include
ln -sf $PKG/usr/include/asm-i386 $PKG/usr/include/asm
That's pretty much it...
Code:
#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-kernel-headers
# If your using 2.4.32-rc1 as stated, what's that make our PKGVER? :-)
# Not such a hot idea IMO....
VERSION=2.4.31
PATCHVER=2.4.32-rc1
PKGVER=2.4.32_rc1
ARCH=i386
BUILD=1
rm -rf $PKG
mkdir -p $PKG/usr/include
cd $TMP
rm -rf linux-$VERSION
tar xjf $CWD/linux-$VERSION.tar.bz2
cd linux-$VERSION
bzip2 -dc $CWD/patch-$PATCHVER.bz2 | patch -p1
cp -R include/asm-$ARCH $PKG/usr/include/asm-$ARCH
cp -R include/linux $PKG/usr/include
( cd $PKG
chown -R root.root .
find usr/include/{asm-$ARCH,linux} -type d -exec chmod 755 {} \;
find usr/include/{asm-$ARCH,linux} -type f -exec chmod 644 {} \; )
( cd $PKG/usr/include
ln -sf asm-$ARCH asm )
mkdir -p $PKG/install
cat << EOF > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
kernel-headers: kernel-headers (Linux kernel include files)
kernel-headers:
kernel-headers: These are the include files from the Linux kernel.
kernel-headers:
kernel-headers: You'll need these to compile most system software for Linux.
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
EOF
# Build the package:
cd $PKG
makepkg -l y -c n $TMP/kernel-headers-$PKGVER-$ARCH-$BUILD.tgz
hey thanks a lot man!!! you went above and beyond with the script!!! thanks!!!
Quote:
Originally posted by Komakino OK, there seems to be some confusion. The kernel source in /usr/src/linux should match the currently running kernel or the nvidia installer will complain. The kernel headers in /usr/include/linux should match the kernel version that glibc was compiled against.
no confusion about that on my part... it's just that i thought i remembered the nvidia installer complaining when the header versions weren't the same as the running kernel (even though it doesn't make sense to do so), not just the source... i know that the headers one needs to have are the ones glibc was compiled against, which made the nvidia installer's complain really weird... but then again i was probably trippin' and yeah maybe it only complains about different source versions, not the headers... or maybe it used to complain but they realized it was retarded and they eventually changed that "feature/bug" of the installer?? i could try the install with the .31 headers when i have compiled .32-rc1 to see if it complains or not... i do know that it SHOULDN'T complain, of course...
Quote:
Originally posted by jong357 Exactally.
Actually, the nvidia driver looks at /lib/modules/$(uname -r)/build and not /usr/src/linux... But yea, same idea.
I was wondering myself why you want to upgrade kernel-headers before a new glibc compile when the existing headers on slack are not even a version number away. Doesn't seem to be a point in it. If the 2.4.32-rc1 patch doesn't touch the header files, then you would be replacing the stock slack header package with an exact duplicate.... :-)
yeah, i'm aware that there's really no technical reason for recreating the kernel-headers package... however i had this (possibly false) memory of the nvidia installer complaining when the kernel headers were a different version from the running kernel (even though it doesn't make sense to complain about that) and so that was the original reason i wanted to make a new headers package when i recompiled the new kernel (so the versions would match)... now it seems like it's just for the sake of education and for the psychological well-being that unexperienced folks like myself get when we do these pointless things...
BTW, i should mention that i will be recompiling glibc (or attempting to ) with the new .32-rc1 headers:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.