Using dev-c++ to develop pthread.h-based multithreaded threads under windows

Source: Internet
Author: User

First, download the Windows version of Pthread

Currently the latest version is:pthreads-w32-2-9-1-release.zip.

Second, unzip the pthread to the specified directory

The directory I chose is: When E:\DEV-CPP\Pthread is complete, the directory will have three more folders: Pre-built.2,pthreads.2,queueuserapcex. iii. Configuring dev-c++ compilation Options
1) Click "Tools" → "Compile Options" → "contents" → "C + + Include files", browse to the Pthread directory you just unzipped, select E:\DEV-CPP\Pthread\Pre-built.2\include, Add.

2) Click "Tools" → "Compile Options" → "contents" → "libraries", browse to the Pthread directory you just unzipped, select E:\DEV-CPP\Pthread\Pre-built.2\lib, Add.
iv. If "undefined reference to ' Pthread_create" error occurs, add the-lpthread parameter to the compiler option Five, finally attach a simple multithreaded example
#include <iostream>#include<pthread.h>#include<cstdio>using namespacestd; void* HJZGG (void*Arg) {       while(1) {cout<<"Hello, everyone!. I am hjzgg!"<<Endl;    GetChar (); }    returnNULL;} intMainintArgsChar*argv[])      {pthread_t tid; Pthread_create (&tid, NULL, HJZGG, NULL);  while(1);//The main thread does not end prematurely    return 0; } 

Using dev-c++ to develop pthread.h-based multithreaded threads under windows

Related Article

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.