Linux下pthread问题
来源:互联网 发布:js阻止事件冒泡 编辑:程序博客网 时间:2024/05/16 15:53
Linux下 undefined reference to "pthread_*" 问题
(2010-05-30 20:29:14)转载▼
标签:
it
分类: LinuxKDevelop:
When you build a project by KDevelop, you'd better add a '-pthread' to the link option if your project includes <pthread.h>. Without that option, KDevelop would report an link error : '/root/kde/oop/src/oop.c:23: undefined reference to `pthread_create'
After rebuild, the program works well.
Eclipse + CDT:
When you use pthread_create in your project, it will compile and link ok. But when you execute the program, the thread will receive a signal SIGSEGV that said: Execution is suspended because of error. Cannot find bounds of current function
I tried to add '-pthread' to the link option of the Eclipse CDT, but it's helpless. I don't know how to correct this.
Linux上编译pthread程序,默认会出错。如题。原因如下。
所以 gcc -o backupfile backupfiles.c -pthread
出现如下错误:
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>
0 0
- Linux下pthread问题
- Linux下pthread开发的一些问题
- Linux下pthread
- linux下fork和pthread混用的问题
- Linux下pthread的读写锁的优先级问题
- linux下fork和pthread混用的问题
- Linux下的多线程编程(linux pthread)
- linux下c程序 daemon、fork与创建pthread的顺序问题
- 话说linux 下的pthread 内存问题 (Valgrind 检测 及定位排除)
- Linux下的多线程编程(pthread)
- Linux下pthread线程库介绍
- Linux下多线程(pthread)编程实例
- linux下添加pthread系列函数原型
- linux下C/C++,多线程pthread
- Linux下用线程pthread加速程序
- linux下C/C++,多线程pthread
- Linux下的多线程编程(pthread)
- Linux下pthread线程库介绍
- XML 说明
- 为什么学习Python及Python环境安装
- magento 模板对应文件
- LeetCode 56 Unique Binary Search Trees II
- fatal error: invalid virtual filesystem overlay file
- Linux下pthread问题
- c++实现线程池
- operator const char*() const
- 在Eclipse中,新建maven项目碰到的问题
- 链表的相交与环问题
- 子线程循环 10 次,接着主线程循环 100 次,接着又回到子线程循环 10 次,接着再回到主线程又循环 100 次,如此循环50次,试写出代码。
- Unity3D性能优化总结
- PAT1043 Is It a Binary Search Tree 水题
- 内存池