Hey,
I'm trying to compile a module for a project at college but when I try to compile this code:
Code:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
int init_module(void)
{
printk("<1>Hello world 1.\n");
// A non 0 return means init_module failed; module can't be loaded.
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
using this make file:
Code:
TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc
${TARGET}.o: ${TARGET}.c
.PHONY: clean
I get the following errors/warnings:
Code:
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes -isystem /lib/modules/`uname -r`/build/include -c -o hello-1.o hello-1.c
hello-1.c:4:55: error: linux/module.h: No such file or directory
hello-1.c:9: warning: no previous prototype for ‘init_module’
hello-1.c: In function ‘init_module’:
hello-1.c:10: warning: implicit declaration of function ‘printk’
hello-1.c: At top level:
hello-1.c:18: warning: no previous prototype for ‘cleanup_module’
hello-1.c: In function ‘cleanup_module’:
hello-1.c:19: error: ‘KERN_ALERT’ undeclared (first use in this function)
hello-1.c:19: error: (Each undeclared identifier is reported only once
hello-1.c:19: error: for each function it appears in.)
hello-1.c:19: error: expected ‘)’ before string constant
make: *** [hello-1.o] Error 1
I followed up the link to /lib/modules/2.6.19-1.2911.fc6/build but it seems to be pointing to /usr/src/kernels/2.6.19-1.2911.fc6-i686/include. Now heres the problem, I don't have a i686 folder here, I have a i586 folder instead. I tried manually inseting the path to the i586 folder instead but I get a load more errors, most of which seem to be division by zero errors. Examples are shown below.
Code:
/usr/src/kernels/2.6.19-1.2911.fc6-i586/include/linux/jiffies.h:33:3: error: #error You lose.
/usr/src/kernels/2.6.19-1.2911.fc6-i586/include/linux/jiffies.h:225:31: error: division by zero in #if
I found the "error You lose." output very useful!
So any ideas on whats wrong here? Should I have the source code for the i686 kernel? Or should the above work okay? If I do need the i686 files then how do I get them?
I hope someone can help me out with this.
Brendan
PS. Sorry about the length of the post.