Система Red hat linux 7.3. Ядро 2.4.18-3. Дефолтная установка. Не компилируется модули ядра.
Вот такой пример(из Померантца)
Hello.c
/* hello.c
* hello,world- kernel module version
*/
/* necessary header files */
/* standard in kernel modules */
#include <linux/kernel.h>
#include <linux/module.h>
/* deal with modversions */
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
/*init module*/
int init_module()
{
printk("Hello world \n");
return 0;
}
/*clean up module*/
void cleanup_module()
{
printk("Short is the life of kernel module\n");
}
makefile для него:
makefile
#makefile for hello.c
CC=gcc
MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODCFLAGS) -c hello.c
echo insmod hello.o
echo rmmod.o
Вот что говорит система:
[root@ush pomerantz]# make
gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -c hello.c
In file included from hello.c:7:
/usr/include/linux/module.h:60: parse error before `atomic_t'
/usr/include/linux/module.h:60: warning: no semicolon at end of struct or union
/usr/include/linux/module.h:60: warning: no semicolon at end of struct or union
/usr/include/linux/module.h:62: parse error before `}'
/usr/include/linux/module.h:62: warning: data definition has no type or storage class
/usr/include/linux/module.h:91: parse error before `}'
hello.c: In function `init_module':
hello.c:18: warning: implicit declaration of function `printk'
make: *** [hello.o] пЫЙВЛБ 1
в чем грабли?