Why can't I pass the compilation? For more information, see Linux programming and kernel. My system is fedora9
I typed a piece of code in the book:
/*************************************** *************************/
# Include
# If defined (CONFIG_SMP)
# Define _ SMP __
# Endif
# If defined (CONFIG_MODVERSIONS)
# Define MODVERSIONS
# Include
# Endif
# Include
Static _ init int init_module (void)
{
Printk (KERN_DEBUG "Hello, kernel! \ N ");
Return (0 );
}
Static _ exit void cleanup_module (void)
{
Printk (KERN_DEBUG "Good-bye, kernel! \ N ");
}
/*************************************** *************************/
The compilation command in the book is:
Gcc-dashes KERNEL _-I/usr/src/linux/include/-DMODULE-Wall-O2-c d_hello.c-o hello. o
Because I have no linux directory under/usr/src/, I changed it:
Gcc-dashes KERNEL _-I/usr/src/kernels/2.6.26.3-29. fc9.i686/include/-DMODULE-Wall-O2-c d_hello.c-o hello. o
A bunch of errors were reported:
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/prefetch. h: 14,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/list. h: 6,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 9,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 112: error: 'config _ X86_L1_CACHE_SHIFT 'undeclared here (not in a function)
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 112: error: requested alignment is not a constant
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/prefetch. h: 14,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/list. h: 6,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 9,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 152: 1: warning: "cache_line_size" redefined
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/pda. h: 7,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/current_64.h: 7,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/current. h: 4,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 15,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/prefetch. h: 14,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/list. h: 6,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 9,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/cache. h: 64: 1: warning: this is the location of the previous definition
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: In function 'Load _ 330 ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 187: error: 'config _ PAGE_OFFSETUL 'undeclared (first use in this function)
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 187: error: (Each undeclared identifier is reported only once
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 187: error: for each function it appears in .)
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: At top level:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/processor. h: 236: error: requested alignment is not a constant
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/thread_info.h: 5,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/thread_info.h: 47,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/preempt. h: 9,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/spinlock. h: 49,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/seqlock. h: 29,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/time. h: 8,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/stat. h: 60,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 10,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/thread_info_64.h: In function 'current _ thread_info ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/thread_info_64.h: 66: error: 'thread _ size' undeclared (first use in this function)
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/thread_info_64.h: In function 'stack _ thread_info ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/thread_info_64.h: 74: error: 'thread _ size' undeclared (first use in this function)
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/elf. h: 7,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 14,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: In function 'elf _ common_init ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 166: error: 'struct pt_regs 'has no member named 'r8'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 166: error: 'struct pt_regs 'has no member named 'r9'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 166: error: 'struct pt_regs 'has no member named 'r10'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 166: error: 'struct pt_regs 'has no member named 'r11'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 167: error: 'struct pt_regs 'has no member named 'r12'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 167: error: 'struct pt_regs 'has no member named 'r13'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 167: error: 'struct pt_regs 'has no member named 'r14'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/elf. h: 167: error: 'struct pt_regs 'has no member named 'r15'
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/mmzone. h: 16,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/green. h: 4,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/slab. h: 12,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/percpu. h: 5,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/local. h: 4,
From/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 19,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/nodemask. h: In function' _ first_node ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/nodemask. h: 233: warning: implicit declaration of function 'Find _ first_bit'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/nodemask. h: In function' _ next_node ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/nodemask. h: 239: warning: implicit declaration of function 'Find _ next_bit'
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/nodemask. h: In function '_ first_unset_node ':
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/nodemask. h: 257: warning: implicit declaration of function 'Find _ first_zero_bit'
In file encoded ded from/usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 21,
From d_hello.c: 9:
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/asm/module. h: 70: 2: error: # error unknown processor family
D_hello.c: At top level:
D_hello.c: 22: error: static declaration of 'init _ module' follows non-static declaration
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 74: error: previous declaration of 'init _ module' was here
D_hello.c: In function 'init _ module ':
D_hello.c: 24: warning: implicit declaration of function 'printtk'
D_hello.c: At top level:
D_hello.c: 28: error: static declaration of 'cleanup _ module' follows non-static declaration
/Usr/src/kernels/2.6.26.3-29. fc9.i686/include/linux/module. h: 75: error: previous declaration of 'cleanup _ module' was here
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.