免费注册 查看新帖 |

Chinaunix

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

[C] 关于linux c编译连接失败的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-05-04 09:09 |只看该作者 |倒序浏览
gcc dxyh_lib.c -Wall -c -o dxyh_lib.o
dxyh_lib.c: 在函数‘Waitpid’中:
dxyh_lib.c:355:5: 警告: 此函数中的‘retpid’在使用前未初始化 [-Wuninitialized]
gcc ftpd.c -Wall -c -o ftpd.o
ftpd.c: 在函数‘ftpd_debug’中:
ftpd.c:155:3: 警告: 格式字符串不是一个字面字符串而且没有待格式化的实参 [-Wformat-security]
gcc ftpd_main.c -Wall -c -o ftpd_main.o
gcc error.c -Wall -c -o error.o
gcc record.c -Wall -c -o record.o
gcc dxyh_thread_lib.c -Wall -c -o dxyh_thread_lib.o
gcc -O3 -Wall -g -lpthread dxyh_lib.o ftpd.o ftpd_main.o error.o record.o dxyh_thread_lib.o -o ftpd_main
record.o: In function `log_open':
record.c.text+0xa0): undefined reference to `sem_init'
dxyh_thread_lib.o: In function `Pthread_create':
dxyh_thread_lib.c.text+0x22): undefined reference to `pthread_create'
dxyh_thread_lib.o: In function `Pthread_join':
dxyh_thread_lib.c.text+0x6: undefined reference to `pthread_join'
dxyh_thread_lib.o: In function `Pthread_detach':
dxyh_thread_lib.c.text+0xa7): undefined reference to `pthread_detach'
dxyh_thread_lib.o: In function `Pthread_kill':
dxyh_thread_lib.c.text+0xed): undefined reference to `pthread_kill'
dxyh_thread_lib.o: In function `Pthread_mutexattr_init':
dxyh_thread_lib.c.text+0x12c): undefined reference to `pthread_mutexattr_init'
dxyh_thread_lib.o: In function `Pthread_mutexattr_setpshared':
dxyh_thread_lib.c.text+0x172): undefined reference to `pthread_mutexattr_setpshared'
dxyh_thread_lib.o: In function `Pthread_key_create':
dxyh_thread_lib.c.text+0x2bb): undefined reference to `pthread_key_create'
dxyh_thread_lib.o: In function `Pthread_once':
dxyh_thread_lib.c.text+0x301): undefined reference to `pthread_once'
dxyh_thread_lib.o: In function `Pthread_setspecific':
dxyh_thread_lib.c.text+0x347): undefined reference to `pthread_setspecific'
dxyh_thread_lib.o: In function `readline_r':
dxyh_thread_lib.c:(.text+0x462): undefined reference to `pthread_getspecific'
dxyh_thread_lib.o: In function `Sem_init':
dxyh_thread_lib.c:(.text+0x65: undefined reference to `sem_init'
dxyh_thread_lib.o: In function `Sem_trywait':
dxyh_thread_lib.c:(.text+0x68: undefined reference to `sem_trywait'
dxyh_thread_lib.o: In function `Sem_wait':
dxyh_thread_lib.c:(.text+0x6b: undefined reference to `sem_wait'
dxyh_thread_lib.o: In function `Sem_post':
dxyh_thread_lib.c:(.text+0x6e: undefined reference to `sem_post'
dxyh_thread_lib.o: In function `Sem_destroy':
dxyh_thread_lib.c:(.text+0x71: undefined reference to `sem_destroy'
collect2: ld 返回 1
make: *** [ftpd_main] 错误 1
我用的ubuntu,怎么回事?以上的头文件我都加了啊,后面-lpthread库也链接了,怎么就错了?

论坛徽章:
0
2 [报告]
发表于 2016-05-04 11:47 |只看该作者
这样的问题,没有源文件别人想给你分析也没办法啊, 除非曾经遇到过一模一样的事情
如果不想泄露自己的代码,可以删除有意义的部分,只留下包含相应函数的最小集合,大家才好分析啊

论坛徽章:
12
2015年辞旧岁徽章
日期:2015-03-03 16:54:1515-16赛季CBA联赛之同曦
日期:2017-03-17 19:13:162016科比退役纪念章
日期:2016-11-07 08:28:12luobin
日期:2016-06-17 17:46:36wusuopu
日期:2016-06-17 17:43:4515-16赛季CBA联赛之福建
日期:2016-01-14 12:49:22程序设计版块每日发帖之星
日期:2015-12-13 06:20:00程序设计版块每日发帖之星
日期:2015-06-08 22:20:00程序设计版块每日发帖之星
日期:2015-06-08 22:20:002015年亚洲杯之科威特
日期:2015-03-24 14:21:272015年迎新春徽章
日期:2015-03-04 09:57:092016科比退役纪念章
日期:2018-04-10 16:20:18
3 [报告]
发表于 2016-05-04 11:52 |只看该作者
-lpthread
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP