LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2008, 12:31 AM   #1
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Rep: Reputation: 38
What are headers?


What are linux headers or kernel headers. What do they do and what are they for?
When compiling a new kernel do you need to compile new the headers also?
 
Old 08-08-2008, 12:35 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
a header tells other software what functions exist in other preexisting code on the system. if you need to use a function in an external library to your own code then rather than needing the source code of the other package all you need is a declaration of what exists within that other code, not the code itself. among other things, that's a header.
 
Old 08-08-2008, 04:43 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by okos View Post
What are linux headers or kernel headers. What do they do and what are they for?
When compiling a new kernel do you need to compile new the headers also?
You don't "compile headers"....headers give the compiler information that it needs to compile from the source code.

Another good definition of a header: A place to define things so you don't have to do it in your code.

The best way to get a feel for how this works would be to write and compile the ever-popular "Hello World" program in C.
 
Old 08-09-2008, 09:45 PM   #4
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by pixellany View Post
You don't "compile headers"....headers give the compiler information that it needs to compile from the source code.

Another good definition of a header: A place to define things so you don't have to do it in your code.

The best way to get a feel for how this works would be to write and compile the ever-popular "Hello World" program in C.
Don't some source codes require the headers for the new kernel in order to compile?

I have an hsf modem. Though you do not install the driver from source, I seem to recall that I could not install the linuxant hsf modem driver with the new kernel. Perhaps there was a different issue?
 
Old 08-09-2008, 10:14 PM   #5
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
A "header" file is a source code file that is "included" in other source files. Structure, type, function and macro definitions are placed in these distinct files so that they may be shared with other source code that relies on these common definitions.

The kernel source code, being a critical component of a system, defines many types, structures, functions and macros for its own use. In order to ensure correct argument passing and data size, the kernel makes these include (aka: headers) files available not only for itself, but also for user programs and device drivers. Any source code that needs to interact with the system typically requires some include files defined for building the kernel itself. Some include files are "included" in user source code merely for a single macro, while other source code may use many of the objects defined in an include file.

An addition to kernel include files, there are also the libc runtime include files, that define the objects defined by the C runtime standard(s). These are some of the most commonly included header files.

Finally, there are other libraries installed and available, such as the openssl or BerkeleyDB libraries, which also makes their header files available to programs that wish to interact with these library.
 
Old 08-10-2008, 04:11 AM   #6
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Headers are simply include files written in C, they are needed when compiling kernel modules along with the kernel source code. Headers are not really "compiled" in and of themselves, but they are needed in the compiling of kernel modules when you could say they are compiled. Also, it's NOT recommended that you upgrade your kernel headers, doing so will cause problems. Usually these are only upgraded when also upgrading glibc.
 
Old 08-10-2008, 04:31 PM   #7
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Original Poster
Rep: Reputation: 38
Thanks

Thanks for the info.

okos
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
2.6.22.6 headers saimike Debian 11 09-11-2007 05:50 PM
2.6.13 Headers Toods Slackware 1 12-21-2005 05:41 AM
headers stabu Linux - Newbie 3 06-16-2005 04:47 PM
mdk 10 headers horatiu_v Linux - Newbie 3 10-06-2004 08:10 AM
what are headers? mep]-[isto Linux - Newbie 7 12-14-2003 05:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration