[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Learning how to compile modules



Dear All,

Decided it was about time I learnt something about the magical
open-source kernel.  So I had a good stare at the source which was
quite fun.  I then borrowed a copy of OReilly's Linux Device Drivers. 
Pretty much on page 1 there's a kernel version of a Hello World
program:

#define MODULE
#include <linux/module.h>

/* start the module - and tell the world about it */
int init_mopdule (void)
{ printk  /* i.e. kernel-print */ ("<1>Hello World!\n"); return 0; }

/* stop the module - and tell the world*/
void cleanup_module (void)
{ printk ("<1>Horatio, I die!\n"); }


That's all.  Simple as can be.  Yet every time I try to complie any
code that contains <linux/whatever> I get reams of error messages. 
Here's a sample:

In file included from /usr/include/linux/sched.h
   from /usr/include/linux/module.h
   from hello.c
/usr/include/linux/pid.h: error: field `task_list' has incomplete type

and another:

/usr/include/linux/bitmap.h:15: error:  `BITS_PER_LONG' undeclared
(first use in this function)

That one seems to indicate that the kernel source tree is incomplete,
as if the header file that defines such things as BITS_PER_LONG is
missing but I've tried this on two debian machines now with identical
results.  Reams of errors.  I've also looked to see whether the errors
contain any messages complaining that the compiler cannot find some
file or other but seen none.  Certainly not in the first page or two.

Can any of you people who program the innards of debian identify the
problem?  Is there something one has to do before doing any kernel
compilation?

The Linux Device Drivers book says that the source is normally to be
found in /usr/linux/but on my machines it seems to be in
/usr/include/linux/.  Is the code in the include directory a proper
full copy of the code?

Any help much appreciated.

Regards, Max



Reply to: