undefined reference to 'pthread_create'问题解决 -- 转
文章出处:http://blog.csdn.net/llqkk/article/details/2854558
由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误:
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<pthread.h>
undefined reference to 'pthread_create'问题解决 -- 转的更多相关文章
- Linux下undefined reference to ‘pthread_create’问题解决
Linux下undefined reference to 'pthread_create'问题解决 在试用Linux 线程模块时,试用pthread_create 函数. 编译命令为 gcc main ...
- undefined reference to `pthread_create'问题解决
在编译pthread有关的程序时,出现undefined reference to `pthread_create'这样的错误. 问题原因: pthread 库不是 Linux 系统默认的库,连接时需 ...
- undefined reference to 'pthread_create'问题解决(转载)
转自:http://blog.csdn.net/llqkk/article/details/2854558 由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子 ...
- Linux下undefined reference to ‘pthread_create’问题解决 zz
接触了Linux系统编程中的线程编程模块,可gcc sample.c(习惯把书上的sample代码写进sample.c文件中)出现“undefined reference to ‘pthread_cr ...
- Linux下编译出现undefined reference to ‘pthread_create’问题解决
1.代码 /* * File: HeartPackageSendAgent.cpp * Author: Pangxiaojian * * * 主要实现:向服务器发送心跳包,每5s向服务器发送一个心跳包 ...
- Debian下undefined reference to ‘pthread_create’问题解决
今天在写线程测试程序(pthread_create)时出现如下问题, 明明在头文件中包含了<pthread.h>,但是仍然提示找不到函数 pthread_create 和 pthread_ ...
- [Linux] Linux下undefined reference to ‘pthread_create’问题解决
问题的原因:pthread不是Linux下的默认的库,也就是在链接的时候,无法找到phread库中函数的入口地址,于是链接会失败. 解决:在gcc编译的时候,附加要加 -lpthread参数即可解决.
- 在linux下编译线程程序undefined reference to `pthread_create'
由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误:undefined reference to 'pthread_create'u ...
- 解决错误---undefined reference to `pthread_create‘
今天试着敲了一下APUE的小例子,遇到了个错误 ----- undefined reference to `pthread_create.(为自己这么晚接触多线程惭愧). 上网上查了一下,借人经验. ...
随机推荐
- HDU 2134 Cuts the cake
http://acm.hdu.edu.cn/showproblem.php?pid=2134 Problem Description Ice cream took a bronze medal in ...
- 固态盘经常性蓝屏处理方法(WIN7/8)
型号:intel 520S 大小;120G 我的是笔记本,这段时间辞职,有了时间折腾自己的电脑系统了,想装WIN8来着,PE下直接把固态盘的分区都干掉了,分了C,D(40G,剩下的空间),安装阶段完美 ...
- Inside Qt Series (全集,共十六篇,不同版本的Qt有不同的实现)
Inside Qt 系列 QObject这个 class 是 QT 对象模型的核心,绝大部分的 QT 类都是从这个类继承而来.这个模型的中心特征就是一个叫做信号和槽(signaland slot)的机 ...
- Dubbo学习(一) Dubbo原理浅析
一.初入Dubbo Dubbo学习文档: http://dubbo.incubator.apache.org/books/dubbo-user-book/ http://dubbo.incubator ...
- 用SQL查询方式显示GROUP BY中的TOP解决方法[转]
用SQL查询方式显示GROUP BY中的TOP怎样用一个SQL语句来显示 分组后每个组的前几位 比如把一个学校所有学生的成绩按班级分组,再显示每个班级前五名的信息. 班级 学生 成绩 一班 ...
- service依赖dao的接口进行数据传输
service依赖dao的接口进行数据传输
- iOS 数组和字典排序
一.数组排序 数组排序方式1: //初始化可变数组 NSMutableArray *arr1=[NSMutableArray arrayWithObjects:@"giu",@&q ...
- MT【151】传球问题
(清华2017.4.29标准学术能力测试10) 甲.乙.丙.丁四人做相互传球的游戏,第一次甲传给其他三人中的一人,第二次由拿到球的人再传给其他三人中的一人,这样的传球共进行了$4$次,则第四次球传回甲 ...
- BZOJ 3143 游走 | 数学期望 高斯消元
啊 我永远喜欢期望题 BZOJ 3143 游走 题意 有一个n个点m条边的无向联通图,每条边按1~m编号,从1号点出发,每次随机选择与当前点相连的一条边,走到这条边的另一个端点,一旦走到n号节点就停下 ...
- 【APIO 2018】铁人两项(圆方树)
题目链接 题意大概是,求有多少三元组$(s,c,f)(s \neq c, c \neq f, s \neq f)$,满足从$s$到$f$有一条简单路径经过$c$. 得到结论: 点双中任意互不相同的三个 ...