免费注册 查看新帖 |

Chinaunix

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

请问个编译问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-17 10:42 |只看该作者 |倒序浏览
我有main.c    file1.h file1.c   file2.h
其中main.c中调用file1.h中声明的函数,file1.h中声明函数的实现在file2.c中。
而file1.c中函数又调用了file2.h中定义的几个简单函数。file2.h中函数就直接定义了,没有再写file2.c文件。

我的makefile如下:
main: main.o file1.o
        gcc -o main main.o file1.o -lm

clean:
        rm -f *.o main

错误信息如下:
gcc -o hash hash_main.o  hash_user.o -lm
hash_user.o: In function `list_add':
hash_user.c.text+0x0): multiple definition of `list_add'
hash_main.o:hash_main.c.text+0x0): first defined here
hash_user.o: In function `list_add_tail':
hash_user.c.text+0x4a): multiple definition of `list_add_tail'
hash_main.o:hash_main.c.text+0x4a): first defined here
hash_user.o: In function `list_del':
hash_user.c.text+0x6e): multiple definition of `list_del'
hash_main.o:hash_main.c.text+0x6e): first defined here
collect2: ld returned 1 exit status


请问这样几个文件怎么组织,哪位大哥帮忙下!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP