Can I get Unix's pthread.h to compile in Windows?

c, multithreading, pthreads, windows

Solution

`pthread.h` is a header for the Unix/Linux (POSIX) API for threads. A POSIX layer such as Cygwin would probably compile an app with `#include <pthreads.h>`.

The native Windows threading API is exposed via `#include <windows.h>` and it works slightly differently to Linux's threading.

Still, there's a replacement "glue" library maintained at http://sourceware.org/pthreads-win32/ ; note that it has some slight incompatibilities with MinGW/VS (e.g. see here).

Problem

If I try to compile a program with ``` #include <pthread.h> ``` in it, I get the error: ``` pthread.h: No such file or directory ``` Is it possible to get this to compile in a Windows environment? I am using Vista with the latest MinGW. I do not want to use the Microsoft Windows Services for UNIX Version 3.5 as I will have to move this to a Unix environment.

Original source

Related problems