[KLUG Members] Compiling Drivers

Peter Buxton members@kalamazoolinux.org
Thu, 22 Jan 2004 00:34:59 -0500


On Wed, Jan 21, 2004 at 04:08:25PM -0500, Jeremy Leonard was only escaped
   alone to tell thee:

> I'm trying to compile drivers but for a kernel version other than the
> one running my system.  I'm running 2.4.20. I need to compile for
> 2.4.18
> 
> What is the proper way to do this?

Install 2.4.18 source code and compile it.

The most important thing you can do, probably, is use the MATCHING
version of gcc, e.g. 2.7.2.x, 2.95.x, 3.3.x, &c. This isn't always
necessary, but is a good idea. `cat /proc/version` will tell you what
was used. If you end up with more than one version of gcc on your
system, change the Makefile variable HOSTCC to point to the proper
version.

> To get it done quickly I edited the make file and changed the part
> that is looking for the kernel source to only look in the directory of
> the source I want to compile for, /home/jeremy/linux.

Don't do that. Change it back.

The kernel is a standalone piece of software. Not only is it statically
linked, but it also has its own linking spec for kernel modules. And it
compiles in its own directory anyway, and it doesn't matter where the
kernel is or what its name is. I keep mine in /var/home/linux-x.x.

p.s. You might have mismatched glibc source. It probably won't be a
problem, again because of the static linking, and your kernel module
won't use glibc functions to communicate with the rest of the kernel.

-- 
Rock music's gain of eccentric, idiosyncratic Robert
Fripp is British industry's loss of a great economist.