LINUX.ORG.RU

компилирование модуля ядра


0

0

red hat 7.3б ядро 2.4.18-3, дефолтная установка. не компилится вот аткой примерчик: /* 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 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

в чем грабли?

anonymous

Ответ на: комментарий от anonymous

Отформатируй _нормально_ пример ибо _это_ можешь читать сам

anonymous
()

См. опцию -I в man gcc

Затем читать uname -r

Затем снова сделать man gcc, но уже для -print-libgcc-file-name

Подумать, снова прочесть man gcc на предмет -c -I, -nostdinc, -nostdlib

Подумать еще раз и сказать

gcc -c -DMODULE -D__KERNEL__ -DLINUX -I- -I. -I/lib/modules/`uname -r`/build/include -I`dirname \`gcc -print-libgcc-file-name\``/include -o hello.o hello.c

Примерно так...

no-dashi ★★★★★
()
Ответ на: комментарий от no-dashi

А вообще-то надо просто правильно прокинуть линки на исходники :))

SnakePAN
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.