linux cmake 多线程 错误 undefined reference to 'pthread_create'
问题原因
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a.
所以在使用pthread_create()创建线程时,需要链接该库。
1. gcc 解决方案
在编译中要加 -pthread参数
gcc thread.c -o thread -pthread
2. cmake 解决方案
修改CMakeLists.txt TARGET_LINK_LIBRARIES中加入 pthread
ADD_EXECUTABLE(your_executable ${source_files})TARGET_LINK_LIBRARIES( your_executable
pthread
)
linux cmake 多线程 错误 undefined reference to 'pthread_create'相关推荐
- linux 线程操作问题undefined reference to ‘pthread_create‘的解决办法(cmake)
linux 线程操作问题undefined reference to 'pthread_create'的解决办法(cmake) 参考文章: (1)linux 线程操作问题undefined refer ...
- linux 内核编译错误 undefined reference to '__mutex_lock_slowpath'
解决办法: 更改 kernel/mutex.c 中的声明以强制将函数保留在目标文件中.您可以像这样使用gcc属性扩展名 __used,具体方法如下: vi kernel/mutex.c 将60行内容, ...
- C/C++ linux 多线程编程报错 :undefined reference to `pthread_create‘
文档声明: 以下资料均属于本人在学习过程中产出的学习笔记,如果错误或者遗漏之处,请多多指正.并且该文档在后期会随着学习的深入不断补充完善.感谢各位的参考查看. 笔记资料仅供学习交流使用,转载请标明出处 ...
- undefined reference to `pthread_create‘(linux下Clion使用thread报错)
完整报错: ====================[ Build | AsyncLogger | Debug ]============================= /snap/clion/1 ...
- Linux下undefined reference to ‘pthread_create’问题解决
Linux下undefined reference to 'pthread_create'问题解决 在试用Linux 线程模块时,试用pthread_create 函数. 编译命令为 gcc main ...
- Linux下undefined reference to ‘pthread_create’问题解决 zz
Linux下undefined reference to 'pthread_create'问题解决 zz 参考文章: (1)Linux下undefined reference to 'pthread_ ...
- [ c++] cmake 编译时 undefined reference to `std::cout‘ 错误的解决方案
[ c++] cmake 编译时 undefined reference to `std::cout' 错误的解决方案 参考文章: (1)[ c++] cmake 编译时 undefined refe ...
- linux使用gcc编译报错“undefined reference to `pthread_create'”
下面这个例子通过一个代码说明两个线程关联一个函数,实现并发操作,预期结果这两个线程都使用了print函数,它们各自执行各自的,不会因为使用了同一个函数而受到影响. my_test.cpp #inclu ...
- undefined reference to 'pthread_create'问题解决
由于是Linux新手,所以现在才开始接触线程编程,照着GUN/Linux编程指南中的一个例子输入编译,结果出现如下错误: undefined reference to 'pthread_create' ...
最新文章
- 网管应当如何管理Windows操作系统
- vuejs和webpack项目(VueComponent)初尝试——瀑布流组件
- Spring写第一个程序HelloSpring
- 大规模图嵌入 示例_ICLR 2020 | 基于谱方法的高效多级图嵌入框架
- 学python将来做什么工作_学Python编程能做什么工作?从事什么岗位?——这些问题你知道吗?...
- 类型转换操作符(C++)
- android 改机型玩王者,全机型60帧一键修改
- gensim实现TF-IDF和LDA模型、sklearn实现聚类
- App集成ApplePay
- ML机器学习基础的编程技巧:
- Rocketmq 消息的同步发送,异步发送,oneway方式
- 扒皮下音悦台的“返回顶部”图标效果
- 微信相关账号需要哪些资质
- 【数论】因数与倍数(一)质数与合数
- Python 将网易云歌单迁移到QQ音乐
- 职高学生计算机学情分析,高职学生学情分析
- (英文版)吴恩达机器学习第三周笔记
- 数码印花为何打印精度太高,成品却越不清晰?
- XCP实战系列介绍06-CANape标定及标定后hex生成操作指导
- 智能对话架构师速成秘诀在这里