Win7 64-bit vs2012 pthread configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.