What are kernel-headers?
Put simply headers are sets of files that define all the application programming interface (API) for a program. So if you're writing some C or C++ code and you want to use the function: getWidget(myContext); Then somewhere in your build path (when you go to compile the code) you need a header that describes where getWidget(Context c) is defined.
Header files end in .h or sometimes .h++. Source code files typically end in .c, .cpp, or .c++ and inside them you'll see references to .h files (sometimes - it can get complicated).
In any event, to compile a program that uses what's called a function library (or just library), you need to have the header files for that library so your compiler can check your code for syntax problems (by comparing what you wrote to the function definition in the header(s)). You don't need the entire source code for the library in order to use the functions - this saves you a lot of space because header files are very small compared to the source files.
You could think of header files like Cliff Notes. Your program needs to know a little bit of information about one of the functions it's using, the header files provide a very brief overview of the function which is enough for you to compile. If you wanted the whole story, you'd need the function's source code.
The reason the header files are not generally included by default is because these days most distributions provide you with binary (pre-compiled) packages for your system. Since you don't have to do any compiling, you don't need to look up any function definitions by their headers, you can simply run your software which has already been verified against the headers when it was compiled and it uses the pre-compiled function libraries (lib*.so) on your system.
If you have the wrong version of a function library on your system, then the pre-compiled binary usually breaks with a segmentation fault or something like that and you either need to get the right library version installed or re-compile the program from source using the library version (and its headers) that you have so it is now referencing the correct API.
Lots of words above, but it all boils down to this:
1. If you install binary packages, you don't need header files (NVidia is an exception that I'll explain)
2. If you install source packages, you'll need the header files and/or source of that package's dependencies
NVIDIA is different because what they do is provide a binary chunk of proprietary code (pre-compiled but not runnable without some additional system-specific code) wrapped in some open source code that you must compile for your machine in order to use the driver. This way, NVidia can use the same core code for their Windows and Linux drivers, and just wrap the core in platform-specific code that hooks the driver into the OS. That's why installing the NVidia proprietary driver needs the kernel headers to be installed in order to compile (but the driver core itself is still proprietary and is actually pre-compiled platform-independent data).
Hope that helps more than it confuses.
P.S. One other thing to keep in mind is that the kernel header packages range in name from 'linux-headers' to 'kernel-headers' and other variations that end in '-headers'. However, most other packages keep their headers in a *-devel[op] or *-dev package. So if you need the Pidgin development headers to compile your own plugin, you'd need to install the libpurple-dev package (libpurple is the Pidgin function library), but the headers for KDE are found in the kde-devel package, and finally the headers for H.323 VoIP library is libopenh323-*-develop.
P.P.S. Source code may be found in the development package or it may be in its own source package (usually *-source) such as sun-java6-source which contains the Sun Java Development Kit (JDK) 6 source files.
Full Post
No comments:
Post a Comment