天嵌 ARM开发社区

 找回密码
 注册
查看: 2510|回复: 1

模块编译出现的错误

[复制链接]
diyu15 发表于 2012-5-5 07:13:40 | 显示全部楼层 |阅读模式
我使用的是Fedora9虚拟机,安装的内核是kernel-2.6.25-14.fc9.src.rpm,
源码目录是/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686,我是在make install结束后进行下面操作的
[root@localhost HelloWorld]# ls
hello.c  makefile
接下来就是模块编译时候遇到的问题
[root@localhost HelloWorld]# gcc -c -I/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/ hello.c
In file included from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/prefetch.h:14,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/list.h:8,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/module.h:9,
                 from hello.c:9:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h:102: 错误:‘CONFIG_X86_L1_CACHE_SHIFT’ 未声明 (不在函数内)
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h:102: 错误:要求的对齐边界不是常量
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h: In function ‘load_cr3’:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h:162: 错误:‘CONFIG_PAGE_OFFSETUL’ 未声明 (在此函数内第一次使用)
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h:162: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h:162: 错误:所在的函数内只报告一次。)
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h: 在顶层:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/processor.h:201: 错误:要求的对齐边界不是常量
In file included from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/thread_info.h:4,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/thread_info.h:35,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/preempt.h:9,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/spinlock.h:49,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/seqlock.h:29,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/time.h:8,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/stat.h:60,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/module.h:10,
                 from hello.c:9:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/thread_info_64.h: In function ‘current_thread_info’:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/thread_info_64.h:66: 错误:‘THREAD_SIZE’ 未声明 (在此函数内第一次使用)
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/thread_info_64.h: In function ‘stack_thread_info’:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/thread_info_64.h:74: 错误:‘THREAD_SIZE’ 未声明 (在此函数内第一次使用)
In file included from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/elf.h:7,
                 from /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/module.h:14,
                 from hello.c:9:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h: In function ‘elf_common_init’:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:165: 错误:‘struct pt_regs’ 没有名为 ‘r8’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:165: 错误:‘struct pt_regs’ 没有名为 ‘r9’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:165: 错误:‘struct pt_regs’ 没有名为 ‘r10’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:165: 错误:‘struct pt_regs’ 没有名为 ‘r11’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:166: 错误:‘struct pt_regs’ 没有名为 ‘r12’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:166: 错误:‘struct pt_regs’ 没有名为 ‘r13’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:166: 错误:‘struct pt_regs’ 没有名为 ‘r14’ 的成员
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/elf.h:166: 错误:‘struct pt_regs’ 没有名为 ‘r15’ 的成员
在包含自 /usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/linux/module.h:21 的文件中,
                 从 hello.c:9:
/usr/src/redhat/BUILD/kernel-2.6.25/linux-2.6.25.i686/include/asm/module.h:70:2: 错误:#error unknown processor family
hello.c: 在顶层:
hello.c:16: 错误:expected ‘)’ before string constant

下面这个是我的hello.c
[root@localhost HelloWorld]# cat hello.c
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static int year=2007;
MODULE_PARM(year,"i");
int hello_init()
{
printk(KERN_WARNING"Hello World %d!\n",year);
return 0;
}

void hello_exit()
{
printk("Hello Exit!\n");
}
module_init(hello_init);
module_exit(hello_exit);

 楼主| diyu15 发表于 2012-5-8 15:03:49 | 显示全部楼层
问题终于被我自己解决掉了,把makefile文件和hello.c文件放在一个文件夹下,然后make一下,生成了hello.ko,再insmod hello.ko就可以看到模块被成功插入了,啪啪啪啪啪啪,给自己鼓掌一下:lol
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-26 07:38 , Processed in 1.062500 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表