# Installing headers manually

## dE_logics

The Linux-headers package is outdated, and always is; I was wondering about moving to linux-3.0.3 but with the right headers (even though I know they are backwards compatible), thus make headers_install is the right idea, but make headers_install doesn't work if linux-headers is not installed (it asks for limits.h for starters). This is putting in a lot of doubt.

So question is how do I install this package manually?

----------

## NeddySeagoon

dE_logics,

You actually have multiple copies of linux-headers installed

The linux-headers package is a stable set of headers for the rest of the system to use, apart from the few things that need to build against the kernel of your choice. Such packages find the headers by following the /usr/src/linux symlink.

Each kernel source tree comes with its own set of linux-headers. If you really want to use kernel provided headers system wide, (you really don't want to do that) make yourself a symlink.

When it breaks, sympathy will be minimal.

----------

## dE_logics

You mean -

ln -s /usr/src/linux/include /usr/include/linux?

----------

## NeddySeagoon

dE_logics,

Something like that ... but its a really bad idea ...

----------

## dE_logics

Looks like there're package conflicts. From /usr/src/linux/include, some directories already exist in /usr/include which belong to glibc.

----------

## Bircoph

 *NeddySeagoon wrote:*   

> 
> 
> Something like that ... but its a really bad idea ...

 

Hmm, can you tell us why?

About half a year ago I had some problems with external module with gentoo linux-headers.

I made make headers_install and copied from /usr/src/linux/usr/include those directories which

are in the linux-headers package.

I have no problems on three different systems so far.

And yes, I do not use gentoo kernel, only vanilla since I had enough with hardly traced in

gentoo-sources. I do not really need any of gentoo patches and am absolutely happy with vanilla

kernel and vanilla sources as described above.

----------

## NeddySeagoon

Bircoph,

The kernel-headers package is updated with changes in the kernel that are needed by other things, in particular glibc.

If you want to use live headers, you should rebuild things that build against the headers.

Its a verybadthing if glibc breaks because of a problem with the headers used to build it.

External kernel modules should not build against the kernel-headers package.

----------

## Bircoph

NeddySeagoon,

so is it normal to use 2.6.39 headers with the 3.0 kernel? I doubt so. I always thought it is a bad idea to use old headers with new kernel or vice versa and they should be as close as possible. I had problems with subversion (bug 263497) due to too large difference between installed kernel headers and current kernel, though headers were newer than the kernel.

----------

## NeddySeagoon

Bircoph,

If it wasn't for the 20th annaversary release of the kernel, 3.0 would have been 2.6.40.

The kernel-headers is always slightly behind the kernel of the day. Its fine to use a 2.6 kernel-headers with a 3.0 kernel.

You can get too big a gap between your kernel and kernel-headers but if you keep both up to date, its rare.

----------

## Bircoph

NeddySeagoon,

 *Quote:*   

> 
> 
> If it wasn't for the 20th annaversary release of the kernel, 3.0 would have been 2.6.40.
> 
> 

 

Yes, I understand that well enough, just put it as the most recent example.

 *Quote:*   

> 
> 
> The kernel-headers is always slightly behind the kernel of the day. Its fine to use a 2.6 kernel-headers with a 3.0 kernel.
> 
> You can get too big a gap between your kernel and kernel-headers but if you keep both up to date, its rare.

 

Usually I update a specific system once in two or three months (with an exception for critical security updates), and kernel is updated in the first place (together with headers), than I rebuild modules and update system set — the latter includes glibc update, it will be bumped in this period. Afterwards the world update follows. It should be no issues with kernel headers in this case and, perhaps, it gives glibc the ability to taste the most recent kernel yummy.

----------

## Hu

New headers with an old kernel may cause a problem if a program using those headers decides to build only the code path that requires a new kernel.  Old headers with a new kernel should work in typical cases.  How else could you update to a newer kernel on an installed system?

----------

## dE_logics

 *Bircoph wrote:*   

>  *NeddySeagoon wrote:*   
> 
> Something like that ... but its a really bad idea ... 
> 
> Hmm, can you tell us why?
> ...

 

You overwrote packages belonging to glibc?

----------

## DaggyStyle

small question, if each kernel has it own linux-headers, why there is a need to a separate linux-headers package?

----------

## Bircoph

 *dE_logics wrote:*   

> 
> 
> You overwrote packages belonging to glibc?

 

I overwrote nothing. The only difference with standard system is linux-headers in package.provided. I unmerged a portage's package and support it manually.

 *DaggyStyle wrote:*   

> 
> 
> small question, if each kernel has it own linux-headers, why there is a need to a separate linux-headers package?
> 
> 

 

Because you can install at /usr/include/ only one set of kernel headers at a time.

----------

## VoidMage

Well, actually headers in linux-headers are stripped from kernel specific stuff and have a few fixes applied, so that the cleanup doesn't break anything.

----------

## DaggyStyle

so why not link to latest headers?

----------

## Bircoph

 *VoidMage wrote:*   

> Well, actually headers in linux-headers are stripped from kernel specific stuff and have a few fixes applied, so that the cleanup doesn't break anything.

 

Isn't make headers_install supposed to prepare tree of headers ready to setup in the system? If it is not, this should be reported as a bug to kernel devs.

Well, I know that Gentoo ships some kernel headers outside of the kernel, e.g. /usr/include/drm. That's Gentoo problem. But well, I install/link only those headers, which are in the linux-headers top directory list.

----------

## dE_logics

 *Bircoph wrote:*   

>  *dE_logics wrote:*   
> 
> You overwrote packages belonging to glibc? 
> 
> I overwrote nothing. The only difference with standard system is linux-headers in package.provided. I unmerged a portage's package and support it manually.
> ...

 

```
equery files glibc | grep '/usr/include/scsi'

/usr/include/scsi

/usr/include/scsi/scsi.h

/usr/include/scsi/scsi_ioctl.h

/usr/include/scsi/sg.h
```

```
cd /usr/src/linux/include/scsi/

ls -1

Kbuild

fc

fc_encode.h

fc_frame.h

iscsi_if.h

iscsi_proto.h

libfc.h

libfcoe.h

libiscsi.h

libiscsi_tcp.h

libsas.h

libsrp.h

osd_attributes.h

osd_initiator.h

osd_protocol.h

osd_sec.h

osd_sense.h

osd_types.h

sas.h

sas_ata.h

scsi.h

scsi_bsg_fc.h

scsi_cmnd.h

scsi_dbg.h

scsi_device.h

scsi_devinfo.h

scsi_dh.h

scsi_driver.h

scsi_eh.h

scsi_host.h

scsi_ioctl.h

scsi_netlink.h

scsi_netlink_fc.h

scsi_scan.h

scsi_tcq.h

scsi_tgt.h

scsi_tgt_if.h

scsi_transport.h

scsi_transport_fc.h

scsi_transport_iscsi.h

scsi_transport_sas.h

scsi_transport_spi.h

scsi_transport_srp.h

scsicam.h

sg.h

srp.h
```

There're a few more folders.

----------

## Bircoph

 *dE_logics wrote:*   

> 
> 
> ```
> equery files glibc | grep '/usr/include/scsi'
> 
> ...

 

He-he, you missed what I wrote earlier:

 *Bircoph wrote:*   

> 
> 
> I made make headers_install and copied from /usr/src/linux/usr/include those directories which 
> 
> are in the linux-headers package. 
> ...

 

I copy only those dirs, which are present in Gentoo shipped linux-headers, there is no scsi dir there, thus no collisions.

----------

## Genone

http://linuxmafia.com/faq/Kernel/usr-src-linux-symlink.html

I think that guy knows a bit about kernel headers   :Twisted Evil: 

----------

## Spidey

That's from 2000, and I guess gentoo uses linux-headers exactly to avoid the related problem.

----------

## dE_logics

What does make headers_install does? Overwrite the old/new headers?

----------

## Bircoph

 *Genone wrote:*   

> http://linuxmafia.com/faq/Kernel/usr-src-linux-symlink.html
> 
> I think that guy knows a bit about kernel headers  

 

Seconded.

 *Quote:*   

> 
> 
> In short, the only people who should update their /usr/include/linux tree are the people who actually make library releases and compile their own glibc, because, if they want to take advantage of new kernel features, they need those new definitions.
> 
> 

 

That's exactly what happens in Gentoo when you update your kernel before glibc update.

 *dE_logics wrote:*   

> 
> 
> What does make headers_install does? Overwrite the old/new headers?
> 
> 

 

By default it installs to the $builddir/usr/include, e.g. /usr/src/linux-<ver>/usr/include. Than you may link whatever you want. It overwrites nothing. Of course, you may change install path, but that's not a default behaviour.

----------

## dE_logics

Got it. Lets see how the packages compile.

----------

## Mr. T.

How do we know if the headers are older than the current kernel?

linux-headers-4.13

gentoo-sources-4.9.76-r1

-- edition --

My explanation may be a bit confused.

The package version of the linux headers is the version of a linux kernel. Thus, my system uses newer kernel headers than my current kernel.

The kernel headers are provided through the kernel sources. Distributions choose to distribute userspace kernel headers (note) associated to a  kernel version.

Developers of the Linux kernel do not directly provide a set of exported headers through an archive (use make headers_install).

Note: The linux-headers package seems to contain internal headers (cf. StackOverflow), probably for the compilation of kernel modules.

See also:

Kernelnewbies

StackExchange

Kernel documentation

StackExchange

Project:Toolchain

helecho

----------

