为什么在 IDE 中"undefined reference to `_imp__pthread_create"错误?
why the error "undefined reference to `_imp__pthread_create" in IDE?
我在windows IDE的Dev c++中得到了两个错误的undefined reference to _imp__pthread_create
和undefined reference to _imp__pthread_join
,我使用的是Dev c++ 5.4.1。为什么会出现这个错误?我该如何解决这个问题?有人能告诉我吗?非常感谢您的时间!!
#include<iostream>
#include<pthread.h>
using namespace std;
void *uss_thread(void*){
cout<<"hello";
}
main()
{
pthread_t tid1;
pthread_create(&tid1, NULL, &uss_thread, NULL);
pthread_join(tid1,NULL);
}
因为你没有链接到lib pthread
。
- 安装在Dev c++
- 在Dev c++中创建新项目 然后转到项目菜单->项目选项->在那个选择"参数选项卡"
- 选择"添加库或对象"选项
- libpthreadGC2 SelectIt"。Dev ++安装目录下的文件:它将在LIB目录下。
- 按Ok
祝你好运
相关文章:
- 在 c++11 中为 pthread 设置调度参数
- 如果不包含 pthread,为什么 GCC 的线程标准库实现会抛出异常?
- pthread只有在线程数量较少时才可以正常工作
- pthread执行时间比顺序执行时间差
- 使用 -pthread 如何不违反 ODR 规则?
- 使用 pthread 的多线程
- 销毁 pthread 互斥体和 C++ 中的取消初始化顺序
- 函数 AfxEndThread 中的读取访问冲突"pThread-> was nullptr"
- 锁定步进pthread互斥
- Pthread段错误,使用指向main中变量的指针
- pthread导致的内存泄漏
- GCC:--静态链接到pthread的整个存档配方在最近的GCC版本中停止工作
- 正确地编写一个类,并将pthread与vlc库和c++一起使用
- 直接读取 pthread 互斥锁的所有者字段是否安全?
- 为什么 pthread 会减慢代码速度?
- 对 pthread CLion 的未定义引用
- C++ 17:pthread的生成文件标志
- 将带有结构的参数传递给 pthread
- Posix 线程类和启动例程 (pthread)
- 在 pthread 中使用共享变量