阅读:2944回复:7
核心模块编译问题求救
#include <linux/kernel.h>
#include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } gcc -O2 -Wall -DMODULE -D__KERNEL__ -I/usr/src/kernels/2.6.18-1.2798.fc6-i586/include -c wtfire.c -o wtfire.o In file included from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/asm/thread_info.h:16, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/thread_info.h:21, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/preempt.h:9, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/spinlock.h:49, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/capability.h:45, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/sched.h:44, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/module.h:9, from wtfire.c:2: /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/asm/processor.h:80: 错误:‘CONFIG_X86_L1_CACHE_SHIFT’ 未声明 (不在函数 内) /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/asm/processor.h:80: 错误:要求的对齐边界不是常量 在包含自 /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/sched.h:49 的文件中, 从 /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/module.h:9, 从 wtfire.c:2: /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/jiffies.h:33:3: 错误:#error You lose. /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/jiffies.h:210:31: 错误:#if 中用零做除数 /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/jiffies.h:210:31: 错误:#if 中用零做除数 /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/jiffies.h:210:31: 错误:#if 中用零做除数 /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/jiffies.h:210:31: 错误:#if 中用零做除数 我为什么就有这么多错,我用的是2.6.18 的核心 |
|
沙发#
发布于:2007-07-07 21:43
后面还少了两行吧,module_init(..............
|
|
板凳#
发布于:2007-07-10 16:34
同问
|
|
地板#
发布于:2007-07-11 21:44
我重新安装了下系统现在不报那错了,莫名奇妙报了这么多错,连系统文件都有问题,头都昏了。
gcc -Wall -g -O2 -I /usr/src/kernels/2.6.18-1.2798.fc6-i586/include -c fire.c In file included from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/asm/thread_info.h:16, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/thread_info.h:21, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/preempt.h:9, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/spinlock.h:49, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/capability.h:45, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/sched.h:44, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/module.h:9, from fire.c:4: /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/asm/processor.h:80: 错误:要求的对齐边界不是常量 In file included from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/list.h:8, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/lockdep.h:12, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/spinlock_types.h:12, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/spinlock.h:78, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/capability.h:45, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/sched.h:44, from /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/module.h:9, from fire.c:4: /usr/src/kernels/2.6.18-1.2798.fc6-i586/include/linux/prefetch.h: 在函数 ‘prefetch_range’ 中: 下面还有很多 |
|
地下室#
发布于:2007-07-11 22:02
后面加了两行,module_init(.............. 也一样
|
|
5楼#
发布于:2007-07-18 20:23
搞定了,难道就没有人知道吗,就是编译连接库文件路径不对
|
|
6楼#
发布于:2007-07-21 13:52
正确的路径是什么?我也有这问题。
|
|
7楼#
发布于:2007-08-14 03:47
/lib/modules/2.6.18-1.2798.fc6/build
|
|