1. First download pthread, after decompression I put on the e-disk.
2. Then use vs2012 to create a new project, then right-click the project Properties, and enter E:\pthreads-w32-2-9-1-release\Pre-built.2\include in the configuration Properties->vc++ directory, include directory ; In the configuration Properties->vc++ directory, enter E:\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64; Remember the platform to select x64, and then configure properties--- Additional dependency input pthreadVC2.lib, configuration complete.
3. Create a new file to enter the test code:
#include <stdio.h>
#include <pthread.h>
#include <assert.h>
void *func (void *para);
int main ()
{
pthread_t pid;
pthread_attr_t attr;
Pthread_attr_init (&ATTR);
Pthread_attr_setscope (&attr,pthread_scope_process);
Pthread_attr_setdetachstate (&attr,pthread_create_detached);
Pthread_create (&pid,&attr,func,null);
printf ("===\n");
GetChar ();
Pthread_attr_destroy (&ATTR);
return 0;
}
void *func (void *para)
{
printf ("Thread starts\n");
pthread_t myid=pthread_self ();
printf ("Thread id=%d", myID);
return NULL;
}
4. Finally put the PthreadVC2.dll in E:\pthreads-w32-2-9-1-release\Pre-built.2\dll\x64 to C:\Windows\System32, otherwise the runtime will eject the missing " PthreadVC2.dll ".
5. The result is shown when you run code last.
Win7 64-bit vs2012 pthread configuration