linux 线程操作问题undefined reference to 'pthread_create'的解决办法(cmake)
问题原因:
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)的更多相关文章
- Linux+CLion+树莓派远程编译时,Cmake编译出现undefined reference to 'pthread_create'的解决办法
在CLion中开发讯飞的linux语音库时编译出现以下问题: undefined reference to 'pthread_create' CLion的cmake配置:修改CMakeLists.tx ...
- Linux Ubuntu运行线程程序出现undefined reference to ‘pthread_create’和undefined reference to ‘pthread_join’错误。
Linux Ubuntu运行线程程序出现undefined reference to ‘pthread_create’和undefined reference to ‘pthread_join’错误. ...
- 问题:eclipse中线程编程编译报错,undefined reference to 'pthread_create'的解决方法(已解决)
问题描述: 在Ubuntu系统中,使用eclipse CDT集成开发环境编写pthread程序,编译时,pthread_create不通过,报错信息是: undefined reference to ...
- Linux下编译出现undefined reference to ‘pthread_create’问题解决
1.代码 /* * File: HeartPackageSendAgent.cpp * Author: Pangxiaojian * * * 主要实现:向服务器发送心跳包,每5s向服务器发送一个心跳包 ...
- Linux+CLion+树莓派远程编译时,Cmake编译出现undefined reference to 'dlopen'的解决办法
在Clion中链接讯飞的语音库并传至树莓派上编译时,出现如下错误. undefined reference to `dlopen' undefined reference to `dlclose' u ...
- 编译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 ...
- Linux 下编译出现 undefined reference to `pthread_create'
这是由于没有链接线程库的原因,只要在编译的时候加入: -lpthread 参数即可. arm-linux-gcc serial.c -o serial -lpthread 查看 ubuntu 版本的命 ...
- ubuntu 下没有pthread库以及报undefined reference to 'pthread_create'的解决方法
https://blog.csdn.net/dyzhen/article/details/79058554
- NDK 提示"undefined reference to xxx“的解决办法
在Android.mk文件的 LOCAL_SRC_FILES后面加入包含该类或函数的文件,用\隔开,\后换行继续添加 例如 LOCAL_SRC_FILES := NDKTest.cpp\bncore. ...
随机推荐
- SQL 调优专题总结
oracle 的优化器: oracle 有两种优化器:基于规则的优化器(rbo/rule based optimizer)和基于代价的优化器(cbo/cost based optimizer). 有时 ...
- (六)动手写第一个shell
1.编辑器.编译器.运行方法(脚本的3种执行方法)(1)shell程序是文本格式的,只要是文本编辑器都可以.但是因为我们的shell是要在linux系统下运行的,所以换行符必须是'\n',而windo ...
- Pexpect模块的安装
Pexpect模块的安装 下载地址:https://pypi.python.org/pypi/pexpect/ 解压后在目录下运行:python ./setup.py install (必须是root ...
- Winform_ComBox三种赋值方式
第一种方法: DataTable dt = new DataTable(); dt.Columns.Add( "name" ); dt.Columns.Add( "val ...
- VC++编译zlib
目录 第1章简介 1 第2章版本1.2.3 2 2.1 编译汇编代码 2 2.1.1 32位汇编 2 2.1.2 64位汇编 5 2.2 Visual C++ 6.0 ...
- Mybatis那一大堆事儿--1
<select id="listAmPerfTime" resultType="Date"> SELECT pam.perf_time AS per ...
- Laravel 分页详解
Laravel分页很简单,但功能又很强大噢! 首先在控制器的方法中使用paginate(页面显示条数)方法,传入页面显示的条数 然后在模板页面使用方法render()来生成html元素 appends ...
- 1029c语言文法2理解
program → external_declaration | program external_declaration <程序>→ <外部声明>|<程序>< ...
- jquery 设置css样式
$("#61dh a").css('color', 多个样式属性 var divcss = { background: '#EEE', width: '478px', mar ...
- ThinkPHP框架如何修改X-Powered-By
以前用ThinkPHP框架开发了一个小网站,前几天查询页面HTTP状态发现,里面有一项: X-Powered-By: ThinkPHP 2.0 这样虽然没什么,但感觉如果别有用心的人查询会知道你是用这 ...