Question : Compiling issues with Kernel module

Hi,

We have been trying to compile the simple hello world kernel modules for 2.6.17 kernel.

As said in the document
http://www.tldp.org/HOWTO/Module-HOWTO/linuxversions.html
this requires to generate .ko files

we were able to get the mod.c file after passing the relocatable to the modpost.
for the next step where we are compile the mod.c to generate .ko we are get some compilation
errors.it says the same for all cmds below.

vermagic.h is in the dir /usr/src/linux-2.6.17/scripts/mod/

cmd: gcc -c h.mod.c
        gcc -c -I /usr/src/linux-2.6.17/  h.mod.c
        gcc -c -I /usr/src/linux-2.6.17/scripts/mod/  h.mod.c
        gcc -c -I /usr/src/linux-2.6.17/  h.mod.c -lh.o

linux/vermagic.h: No such file or directory
h.mod.c:5: warning: parameter names (without types) in function declaration
h.mod.c:5: warning: data definition has no type or storage class
h.mod.c:9: `KBUILD_MODNAME' undeclared here (not in a function)
h.mod.c:9: initializer element is not constant
h.mod.c:9: (near initialization for `__this_module.name')
h.mod.c:10: `init_module' undeclared here (not in a function)
h.mod.c:10: initializer element is not constant
h.mod.c:10: (near initialization for `__this_module.init')
h.mod.c:17: parse error before "__attribute_used__"
h.mod.c:19: warning: initialization makes integer from pointer without a cast
h.mod.c:19: warning: data definition has no type or storage class

we tried ti include the directory with -I option as well

" You compile the .mod file and link the result with the original .o file to make a .ko file. "
request you all to shed some more light on this, may be with an example



Answer : Compiling issues with Kernel module

Start from creating makefile as decribed in http://www.tldp.org/LDP/lkmpg/2.6/html/x121.html
Most of these errors are because some defines are not set. Please try again and be back with next errors - if emerge any.
Another link with example: http://kerneltrap.org/node/6955
Random Solutions  
 
programming4us programming4us