undefined reference to `pthread_create'问题解决
在编译pthread有关的程序时,出现undefined reference to `pthread_create'这样的错误。
问题原因:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。
问题解决:
方法一:
在编译中要加 -lpthread参数
gcc thread.c -o thread -lpthread
thread.c是写的源程序,不要忘了加上头文件#include<pthread.h>
方法二:
编译时加-lrt参数
gcc thread.c -o thread -lrt
参考:
http://blog.csdn.net/llqkk/article/details/2854558
http://bbs.chinaunix.net/thread-1586752-1-1.html
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'问题解决 -- 转
文章出处:http://blog.csdn.net/llqkk/article/details/2854558 由于是Linux新手,所以现在才开始接触线程编程,照着GUN/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.(为自己这么晚接触多线程惭愧). 上网上查了一下,借人经验. ...
随机推荐
- KEIL编译错误总结:
1 expected an identifier:#define宏定义常量后,如果再用前面定义的常量作为枚举常量就会报错,方法,去掉#define宏定义
- java普通servlet三层开发模式图
- HTTP Response中的Status-Code
1XX : 通知信息.请求被接收,继续处理2XX : 成功.请求动作被成功接收.理解和接受3XX : 重定向.需要其他的动作来完成这个请求4XX : 客户端错误.请求包含错误的语法或者缺少语法5XX ...
- c#生成缩略图
publicstaticvoidGenThumbnail(Image imageFrom,stringpathImageTo,intwidth,intheight) { ...
- 查看linux的版本
1. uname -a ~$ uname -a Linux lubuntu-Vostro-A840 3.19.0-73-generic #81-Ubuntu SMP Tue Oct 18 16:02: ...
- struts2中action中的通配符
struts中一个正常的最普通不过的action是这样子的 <package name="default1" namespace="/gys" exten ...
- POJ 2396 Budget【网络流】
题意: cas //测试数据组数 n m //行数 列数 a1 a2 ... an //每行的和 b1 b2 ... bn //每列的和 q ...
- IOS学习之路- 运行过程
1. 执行Main函数(在main.m文件中) 2. 加载MainStoryborad.storyboard文件 * 创建ViewController文件 * 根据storyboard文件中描述创建V ...
- Hadoop2.6.0错误
错误1: WARN hdfs.DFSClient: DataStreamer Exception org.apache.hadoop.ipc.RemoteException(java.io.IOExc ...
- ubuntu更换软件源
ubuntu更换软件源 /etc/apt/source.list 163: deb http://mirrors.163.com/ubuntu/ trusty main restricted u ...