问题原因:

pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a.

所以在使用pthread_create()创建线程时,需要链接该库。

1. 终端:问题解决:
在编译中要加 -pthread参数

 gcc thread.c -o thread -pthread

2. qt的cmake配置: 可以修改CMakeLists.txt:

Here is the right answer:

ADD_EXECUTABLE(your_executable ${source_files})

TARGET_LINK_LIBRARIES( your_executable
pthread
)

equivalent to

-pthread

linux 线程操作问题undefined reference to 'pthread_create'的解决办法(cmake)的更多相关文章

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

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

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

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

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

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

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

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

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

    在Clion中链接讯飞的语音库并传至树莓派上编译时,出现如下错误. undefined reference to `dlopen' undefined reference to `dlclose' u ...

  6. 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法

    lib/libQtGui.so: undefined reference to `ts_read_raw' /lib/libQtGui.so: undefined reference to `ts_o ...

  7. Linux 下编译出现 undefined reference to `pthread_create'

    这是由于没有链接线程库的原因,只要在编译的时候加入: -lpthread 参数即可. arm-linux-gcc serial.c -o serial -lpthread 查看 ubuntu 版本的命 ...

  8. ubuntu 下没有pthread库以及报undefined reference to 'pthread_create'的解决方法

    https://blog.csdn.net/dyzhen/article/details/79058554

  9. NDK 提示"undefined reference to xxx“的解决办法

    在Android.mk文件的 LOCAL_SRC_FILES后面加入包含该类或函数的文件,用\隔开,\后换行继续添加 例如 LOCAL_SRC_FILES := NDKTest.cpp\bncore. ...

随机推荐

  1. poj1819Disks

    链接 题意:从左到右按顺序给你n个圆的半径,把左右两边想象成两堵墙的话,就是左右两边向里挤压,问哪些圆是对最后的宽度不影响. 刚开始理解错了,..以为怎么放圆使宽度最小.. 这样就可以尽量使每个圆向左 ...

  2. STM32学习笔记(一) 如何新建一个STM32工程模板

    学习stm32,第一步就是选择开发工具了,GCC,MDK,IAR每一种都有自己的优劣势,这里我选择使用MDK软件实现STM32模板.当然如果想更快的接触stm32实例,领略嵌入式开发的魅力,STM也提 ...

  3. iframe页面调用父窗口JS函数

    A页面iframe 页面B, 此时 如果要在B页面调用父页面A的函数 B页面写法 parent.functionName(); 错误1: 解决办法 var js_domain_async = 'bai ...

  4. Android星星评分控件RatingBar的使用

    在Android的开发中,有一个叫做评分控件RatingBar,我们可以使用该控件做等级划分.评分等作用,星星形状显示,也可以半星级别,我们来看一下评分控件如何使用. 布局文件中定义控件以及属性,这里 ...

  5. 免费在线客服QQ_网页接入及使用说明

    首先,注册一个QQ (haha,我觉得也是废话) 到QQ推广的网站设置,生成代码 链接:http://shang.qq.com/v3/widget.html 选择“免费开通”,然后就会看到下图,一般只 ...

  6. Spring的线程池ThreadPoolTaskExecutor使用案例

    1.Sping配置文件 <!-- 线程池配置 --> <bean id="threadPool" class="org.springframework. ...

  7. 基于OGG的Oracle与Hadoop集群准实时同步介绍

    版权声明:本文由王亮原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/220 来源:腾云阁 https://www.qclou ...

  8. 如何使div左右倾斜

    <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" ...

  9. python知识总结

    LIST:Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素,用[]包裹.例如 classmates = ['Michael', 'Bob', 'T ...

  10. 父类中“this” 指向问题

    “this.字段”如果出现在父类代码中,指的就是父类属性. “this.方法”不管出现在父类还是子类代码中,指的都是子类方法. “this.字段”如果出现在子类代码中,指的就是子类属性. 在程序的时候 ...