Reputation: 3383
I have a codebase that makes extensive use of pthread.h. On a windows visual studio project, this obviously doesn't work since pthreads is a unix utility.
I know there exists pthread-win32 or something of the sort, but is there a way to have a codebase use this, without replacing all of the pthread code?
edit: I'd prefer to not have to go through and replace all the pthread calls. This is my question
Upvotes: 12
Views: 50939
Reputation: 400592
If the code is very heavily *nix-based, you'll probably have the best luck compiling it with Cygwin+GCC. If pthreads is the only *nix dependency and you'd like to avoid the Cygwin dependency, then you should go with Pthreads-win32.
Upvotes: 3
Reputation: 4489
Try http://sourceware.org/pthreads-win32/. While I've never used that particular library, I've had luck using some windows ports/abstraction layers of POSIX APIs.
Upvotes: 7
Reputation: 100151
I would recommend boost as a library that contains a platform-independent thread abstraction. I don't think you'll find any attempt to call the pthread functions themselves to be satisfying. It's also not very hard to map pthread to Win32 for yourself.
Upvotes: 4