文章出处: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'问题解决 -- 转的更多相关文章

  1. Linux下undefined reference to ‘pthread_create’问题解决

    Linux下undefined reference to 'pthread_create'问题解决 在试用Linux 线程模块时,试用pthread_create 函数. 编译命令为 gcc main ...

  2. undefined reference to `pthread_create'问题解决

    在编译pthread有关的程序时,出现undefined reference to `pthread_create'这样的错误. 问题原因: pthread 库不是 Linux 系统默认的库,连接时需 ...

  3. undefined reference to 'pthread_create'问题解决(转载)

    转自:http://blog.csdn.net/llqkk/article/details/2854558 由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子 ...

  4. Linux下undefined reference to ‘pthread_create’问题解决 zz

    接触了Linux系统编程中的线程编程模块,可gcc sample.c(习惯把书上的sample代码写进sample.c文件中)出现“undefined reference to ‘pthread_cr ...

  5. Linux下编译出现undefined reference to ‘pthread_create’问题解决

    1.代码 /* * File: HeartPackageSendAgent.cpp * Author: Pangxiaojian * * * 主要实现:向服务器发送心跳包,每5s向服务器发送一个心跳包 ...

  6. Debian下undefined reference to ‘pthread_create’问题解决

    今天在写线程测试程序(pthread_create)时出现如下问题, 明明在头文件中包含了<pthread.h>,但是仍然提示找不到函数 pthread_create 和 pthread_ ...

  7. [Linux] Linux下undefined reference to ‘pthread_create’问题解决

    问题的原因:pthread不是Linux下的默认的库,也就是在链接的时候,无法找到phread库中函数的入口地址,于是链接会失败. 解决:在gcc编译的时候,附加要加 -lpthread参数即可解决.

  8. 在linux下编译线程程序undefined reference to `pthread_create'

    由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误:undefined reference to 'pthread_create'u ...

  9. 解决错误---undefined reference to `pthread_create‘

    今天试着敲了一下APUE的小例子,遇到了个错误 -----  undefined reference to `pthread_create.(为自己这么晚接触多线程惭愧). 上网上查了一下,借人经验. ...

随机推荐

  1. HDU 2134 Cuts the cake

    http://acm.hdu.edu.cn/showproblem.php?pid=2134 Problem Description Ice cream took a bronze medal in ...

  2. chdir

    <?php //获得当前目录 echo getcwd(); echo "<br />"; //改变为 images 目录 chdir("images&q ...

  3. SQL DATACOMPARE 实现两个数据库的同步处理.

    1. SQL DATACOMPARE 实现 两个数据库的同步 安装破解. 然后进行对比 然后进行 deploy 生成sql 等. 貌似很好用 但是前提是数据库是可用的... 这里面能够看到 生成的脚本 ...

  4. 设置session的过期时间

    1)修改php.ini文件中的gc_maxlifetime变量就可以延长session的过期时间了 session.gc_maxlifetime = 86400 然后,重启你的web服务(一般是apa ...

  5. centos 升级内核(编译安装)

    yum install -y wget gcc gc bc gd make perl ncurses-devel xz下载地址:https://www.kernel.org#tar -Jxvf lin ...

  6. linux下tomcat、jenkins环境搭建

    1.安装JDK  我不列出来了,自行百度 java -version 2.安装tomcat (1)将下载的tomcat压缩包 tar -zxvf apache-tomcat-8.5.29.tar.gz ...

  7. URAL 1969. Hong Kong Tram

    有一个trick就是没想到,枚举第二段时间后,要检测该火车能否继续跑一圈来判断,不能先检测前半圈能不能跑加进去后在检测后半段: // **** 部分不能放在那个位置: 最近代码导致的错误总是找不出,贴 ...

  8. Matplotlib风羽自定义

    [前言]对于气象专业的小学生来说,风场是预报重要的参考数据,我们所知的风羽有四种:短线代表风速2m/s,长线代表风速4m/s,空心三角代表风速20m/s,实心三角代表风速50m/s.而matplotl ...

  9. 谷歌钦定的编程语言Kotlin大揭秘

    第一时间关注程序猿(媛)身边的故事 谷歌钦定的编程语言Kotlin大揭秘 语法+高级特性+实现原理:移动开发者升职加薪宝典! 谷歌作为世界级的科技公司巨头,强悍的技术研发与创新能力使其一直是业界的楷模 ...

  10. BZOJ 3357: [Usaco2004]等差数列

    3357: [Usaco2004]等差数列 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 338  Solved: 160[Submit][Statu ...