免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 2433 | 回复: 10
打印 上一主题 下一主题

写了个简单的模块,编译不过去 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-05-17 15:58 |只看该作者 |倒序浏览
*********hello.c

#include<linux/init.h>
#include<linux/module.h>
#include"hello.h"

MODULE_LICENSE("Dual BSD/GPL");


static int hello_init(void)
{
        printk(KERN_ALERT "hello the world\n");
                msg();
        return 0;
}

static void hello_exit(void)
{
        printk(KERN_ALERT "Goodbye\n");
}

module_init(hello_init);
module_exit(hello_exit);

*************hello.h
void msg(void);

***************hello2.c
void msg(void)
{
        printk(KERN_ALERT "I am in the hello2.c\n");
}

****************makefile
obj-m :=hello.o
hello-objs:= hello.o hello2.o hello.h

论坛徽章:
0
2 [报告]
发表于 2006-05-17 23:49 |只看该作者
Makefile有问题
贴详细编译错误!

论坛徽章:
0
3 [报告]
发表于 2006-05-18 10:38 |只看该作者
受不了,既然你是新手,当然需要查一下别人是怎么编译的了,网上教新手的例子随便找,为什么马上就来问呢?

论坛徽章:
0
4 [报告]
发表于 2006-05-18 10:47 |只看该作者
makefile是放在源码树中的 linux/drivers/char/chen下
在char中的makefile加了一行
obj-m+=chen/hello.o
之前只写一个单文件(没有msg函数)的模块没有问题,现在我想试试多个文件
报错说msg()没定义
内核2.6.16.2
我觉得应该不是makefile得问题

论坛徽章:
0
5 [报告]
发表于 2006-05-18 11:00 |只看该作者
是挺简单的!
努力!!!!
共同进步

论坛徽章:
0
6 [报告]
发表于 2006-05-18 11:10 |只看该作者

论坛徽章:
0
7 [报告]
发表于 2006-05-18 11:42 |只看该作者
简单可编不过去,很郁闷

论坛徽章:
0
8 [报告]
发表于 2006-05-18 17:38 |只看该作者
原帖由 berniechen 于 2006-5-18 10:47 发表
makefile是放在源码树中的 linux/drivers/char/chen下
在char中的makefile加了一行
obj-m+=chen/hello.o
之前只写一个单文件(没有msg函数)的模块没有问题,现在我想试试多个文件
报错说msg()没定义
内核2. ...


hello2没加吧

论坛徽章:
0
9 [报告]
发表于 2006-05-19 09:07 |只看该作者
hello2不用加
obj-m是最后编成的模块
****************makefile
obj-m :=hello.o
hello-objs:= hello.o hello2.o hello.h
在这个makefile里加就可以了

论坛徽章:
0
10 [报告]
发表于 2006-05-19 09:47 |只看该作者
LZ?看我给你发的连接了么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP