当前位置:网站首页>Visual studio2019 configuration uses pthread
Visual studio2019 configuration uses pthread
2022-08-11 06:32:00 【rest of my life love static】
一、下载pthread
pthreadThe url
下载pthread的最新版pthreads-w32-2-9-1-release.zip,然后解压,Will get the following three folder:
二、配置pthread
1、右键项目,选择属性
2、在VC++目录配置包含目录和库目录
包含目录:配置的是include所在的路径(D:\Android\c++\pthreads-w32-2-9-1-release\Pre-built.2\include)
库目录:配置的是lib所在的路径,If it's configuration is32位的平台,就选择D:\Android\c++\pthreads-w32-2-9-1-release\Pre-built.2\lib\x86;如果配置64位的平台,就选择D:\Android\c++\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64
3、编写如下代码,并运行
#include <iostream>
// 必须的头文件
#include <pthread.h>
using namespace std;
#define NUM_THREADS 5
// 线程的运行函数
void* say_hello(void* args)
{
cout << "Hello Runoob!" << endl;
return 0;
}
int main()
{
// 定义线程的 id 变量,多个变量使用数组
pthread_t tids[NUM_THREADS];
for (int i = 0; i < NUM_THREADS; ++i)
{
//参数依次是:创建的线程id,线程参数,调用的函数,传入的函数参数
int ret = pthread_create(&tids[i], NULL, say_hello, NULL);
if (ret != 0)
{
cout << "pthread_create error: error_code=" << ret << endl;
}
}
//等各个线程退出后,进程才结束,否则进程强制结束了,线程可能还没反应过来;
pthread_exit(NULL);
}
3-1、Running will quote us the following error:
解决方案:
打开pthread.h文件,添加以下内容:
#define HAVE_STRUCT_TIMESPEC
#pragma comment(lib,"pthreadVC2.lib")
3-2、再次运行,Will quote us the following exception:
解决方案:原因是找不到对应的dll文件,Need to manually put the correspondingdll文件拷贝到对应的目录下
Pre-built.2\dll\x86下的文件拷贝到C:\Windows\SysWOW64目录下
Pre-built.2\dll\x64下的文件拷贝到C:\Windows\System32目录下
PS:Direct copy the correspondingdllFile to the corresponding directory,而不是dll文件夹的文件夹
再次运行,就成功了.
边栏推荐
- 论文解读TransFG: A Transformer Architecture for Fine-grained Recognition
- typescript学习日记,从基础到进阶(第二章)
- STM32F4-正点原子探索者-SYSTEM文件夹下的delay.c文件内延时函数详解
- 张小龙的微信公开课(2019年)
- 论文解读:GAN与检测网络多任务/SOD-MTGAN: Small Object Detection via Multi-Task Generative Adversarial Network
- C语言实现猜数字(附带源码,可直接运行)
- gerrit 配置SSH Key和账号、邮箱信息
- USB URB
- Introduction of safety helmet wearing recognition system
- 推出 Space Marketplace 测试版 | 新发布
猜你喜欢
华为云IOT平台设备获取api调用笔记
从概念认识AI
Kotlin 增量编译的新方式 | 技术解析
贡献者任务第三期精彩来袭
OpenMLDB官网升级,神秘贡献者地图带你快速进阶
Maykle Studio - HarmonyOS Application Development Fourth Training
vscode插件开发——代码提示、代码补全、代码分析(续)
CMT2380F32模块开发10-高级定时器例程
360° large field of view helmet recognition system-deep learning intelligent video analysis
The selection points you need to know about the helmet identification system
随机推荐
Generic kernel and userspace Makefiles
谨此留个纪念
弱监督语义分割CLIMS(CVPR2022)
我心仪的数据集—目标检测为主
如何快速转行做产品经理
Node-1.高性能服务器
OpenMLDB官网升级,神秘贡献者地图带你快速进阶
CMT2380F32模块开发6-flash例程
Mei cole studios - deep learning second BP neural network
mount命令--挂载出现只读,解决方案
vscode插件开发——代码提示、代码补全、代码分析(续)
构建面向特征工程的数据生态 ——拥抱开源生态,OpenMLDB全面打通MLOps生态工具链
使用c语言实现井字棋(有源码,可以直接运行)
CMT2380F32模块开发10-高级定时器例程
华为云IOT平台设备获取api调用笔记
Waymo dataset usage introduction (waymo-open-dataset)
Solutions to the 7th Jimei University Programming Contest (Individual Contest)
目标检测——卷积神经网路基础知识
IIC 和 SPI
HTTP缓存机制详解