环境: Window VS 2010
1 先去下载pthread库 ftp://sources.redhat.com/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe
2 解压exe文件,将Pre-built.2目录下的include 和lib拷贝到工程目录下
3 VS设置附加包含目录--include,附加库目录--lib
4 测试代码
#include <stdio.h> #include <iostream> #include "include\pthread\pthread.h" // 添加 pthread库 #pragma comment(lib, "pthreadVC2.lib")//不可缺少,否则编译报错 using namespace std; void *PthreadFun(void *arg) { i