shihyu
module 編譯錯誤
[code]#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
printk("Hello World!/n");
return 0;
}
void cleanup_module(void)
{
printk("Hello World Module was removed!");
}
MODULE_LICENSE("GPL");[/code]
[code]CC=gcc
CFLAGS = -O2 -DMODULE -D__KERNEL__ -Wall /
-I/usr/src/linux-headers-2.6.24-1-686/include
HelloWorldModule.o: HelloWorldModule.c
$(CC) $(CFLAGS) -c HelloWorldModule.c
install:
/sbin/insmod HelloWorldModule.o
remove:
/sbin/rmmod HelloWorldModule
clean:
rm -f HelloWorldModule.o
[/code]
出現下面錯誤訊息有朋友知道是什麼原因嗎?
[code]
gcc -O2 -DMODULE -D__KERNEL__ -Wall -I/usr/src/linux-headers-2.6.24-1-686/include -c HelloWorldModule.c
In file included from /usr/src/linux-headers-2.6.24-1-686/include/asm/processor.h:4,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/prefetch.h:14,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/list.h:8,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/module.h:9,
from HelloWorldModule.c:1:
/usr/src/linux-headers-2.6.24-1-686/include/asm/processor_64.h:79: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
/usr/src/linux-headers-2.6.24-1-686/include/asm/processor_64.h:79: error: requested alignment is not a constant
/usr/src/linux-headers-2.6.24-1-686/include/asm/processor_64.h:200: error: requested alignment is not a constant
In file included from /usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:35,
from /usr/src/linux-headers-2.6.24-1-686/include/asm/elf.h:8,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/elf.h:6,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/module.h:14,
from HelloWorldModule.c:1:
/usr/src/linux-headers-2.6.24-1-686/include/asm/vm86.h:22:1: warning: "VM_MASK" redefined
In file included from /usr/src/linux-headers-2.6.24-1-686/include/asm/processor.h:4,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/prefetch.h:14,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/list.h:8,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/module.h:9,
from HelloWorldModule.c:1:
/usr/src/linux-headers-2.6.24-1-686/include/asm/processor_64.h:29:1: warning: this is the location of the previous definition
In file included from /usr/src/linux-headers-2.6.24-1-686/include/asm/elf.h:8,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/elf.h:6,
from /usr/src/linux-headers-2.6.24-1-686/include/linux/module.h:14,
from HelloWorldModule.c:1:
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h: In function ‘user_mode’:
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:50: error: ‘SEGMENT_RPL_MASK’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:50: error: (Each undeclared identifier is reported only once
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:50: error: for each function it appears in.)
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:50: error: ‘USER_RPL’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h: In function ‘user_mode_vm’:
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:54: error: ‘SEGMENT_RPL_MASK’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.24-1-686/include/asm/ptrace.h:54: error: ‘USER_RPL’ undeclared (first use in this function)
make: *** [HelloWorldModule.o] Error 1
[/code]
謝謝