设为首页 加入收藏

TOP

一步一步学Linux C:undefined reference to ‘pthread_create'问题解决
2015-02-03 01:47:23 来源: 作者: 【 】 浏览:24
Tags:步一步 Linux undefined reference pthread_create' 问题 解决

undefined reference to 'pthread_create'


undefined reference to 'pthread_join'


问题原因:


pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。


问题解决:


在编译中要加 -lpthread参数


gcc thread.c -o thread -lpthread


thread.c为你些的源文件,不要忘了加上头文件#include


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++中<array>的使用 下一篇Linux中的2>&1使用学习

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: