1. 下载pthreads win32源代码:
ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.tar.gz
2. 编译静态库:
make clean GC-static
在根目录下面生成libpthreadGC2.a
3. 将生成的libpthreadGC2.a拷贝到mingw库目录下,将pthread.h, sched.h, semaphore.h拷贝到INCLUDE目录下
4. 使用libpthread库,
在程序起始处对libpthread作初始化:
#if defined(PTW32_STATIC_LIB)
ptw32_processInitialize();
ptw32_processInitialize();
#endif
5. 编译时确保传入-DPTW32_STATIC_LIB,链接时加入-lpthreadGC2, OK!
5. 编译时确保传入-DPTW32_STATIC_LIB,链接时加入-lpthreadGC2, OK!