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

上网上查了一下,借人经验。

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

问题解决:
    在编译中要加 -lpthread参数
    gcc 6.c -o 6 -lpthread
    6.c为你些的源文件,不要忘了加上头文件#include<pthread.h>

解决错误---undefined reference to `pthread_create‘的更多相关文章

  1. Linux Ubuntu运行线程程序出现undefined reference to ‘pthread_create’和undefined reference to ‘pthread_join’错误。

    Linux Ubuntu运行线程程序出现undefined reference to ‘pthread_create’和undefined reference to ‘pthread_join’错误. ...

  2. [转载]解决linux 下多线程错误 undefined reference to `sem_init'

    转自:https://blog.csdn.net/yzycqu/article/details/7396498?utm_source=copy 解决linux 下多线程错误 undefined ref ...

  3. 问题:eclipse中线程编程编译报错,undefined reference to 'pthread_create'的解决方法(已解决)

    问题描述: 在Ubuntu系统中,使用eclipse CDT集成开发环境编写pthread程序,编译时,pthread_create不通过,报错信息是: undefined reference to ...

  4. Linux+CLion+树莓派远程编译时,Cmake编译出现undefined reference to 'pthread_create'的解决办法

    在CLion中开发讯飞的linux语音库时编译出现以下问题: undefined reference to 'pthread_create' CLion的cmake配置:修改CMakeLists.tx ...

  5. 错误 undefined reference to __cxa_guard_acquire/release

    用gcc编译 c++ 程序时,出现错误 undefined reference to __cxa_guard_acquire linker error, 但是用icc可以正常编译, 问题出在stati ...

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

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

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

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

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

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

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

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

随机推荐

  1. WebApi基础

    1:当Controller中有相同参数的方法时,请求调用会报错 [HttpGet] public IEnumerable<string> Resturn() { return new st ...

  2. protect,internal的区别

    protected: 爷爷有一张银行卡,爸爸可以用,儿子也可以用,隔壁老王不可以用(因为老王跟爷爷没有继承关系) internal: 王总有一张银行卡,秘书可以用,经理可以用,王总儿子不可以用(因为银 ...

  3. 大家都是怎么看待STO的?

    STO,全称为「Security Token Offer」,即证券型通证发行.STO是2017年底从美国开始流行的,对于在美国注册的公司,STO是一个合法合规的ICO. 对于STO,大家都是怎么看待的 ...

  4. FI 常用表

    FI 常用表 GL部分:FAGLFLEXT(FMGLFLEXT)   总账汇总表 GLT0        旧总帐汇总表           SKA1        总账科目主记录 (科目表)      ...

  5. (转)nginx-rtmp-module和ffmpeg搭建实时HLS切片

    1.rtmp服务器 nginx+pcre+zlib+openssl+nginx-rtmp-module ./configure \ --prefix=/usr/local/nginx \ --sbin ...

  6. POJ - 1611 The Suspects 【并查集】

    题目链接 http://poj.org/problem?id=1611 题意 给出 n, m 有n个人 编号为 0 - n - 1 有m组人 他们之间是有关系的 编号为 0 的人是 有嫌疑的 然后和 ...

  7. shell的面试题

    在网上看到一道考shell的题--统计出一个文件夹下大小大于7MB的文件夹 好,我也来装一下深沉,个人觉得,这道题主要考的是对经常使用的linux的熟练程度(我不是很熟,哈哈),题目要统计,主要用到两 ...

  8. 算法(Algorithms)第4版 练习 1.3.23 1.3.22

    1.3.23 When it comes time to update t.next, x.next is no longer the original node following x, but i ...

  9. python正则表达提取文本好文

    摘自: http://www.cnblogs.com/rj81/p/5933838.html

  10. 转载h5问题总结

    判断微信浏览器 function isWeixin(){ var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger ...