I found an implementation for pthreads on Windows here, but I couldn't get it to work right. Can anyone help me to install pthreads ? Like where to put DLLs, .lib, and .h files?
Also, as an environment I'm not using Visual Studio, but Codeblocks with Mingw.
I usually develop on Linux, but this project has to be on Windows, and I've already got some code implemented using pthreads, so I don't want to use Windows Threads from 'windows.h'.
The .dll can go in any directory listed in your PATH environment variable.
The .lib file can go in any directory listed in your LIB environment variable.
The .h files can go in any directory listed in your INCLUDE environment variable.
Also see the FAQs page of the link you shared .
Read Q6, Q7, Q8.
For Visual C++ Users (not MingW), follow this steps:
1) download "ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip"
2) in the extraction folder, open the subfolder "Pre-built.2" and you should see the following files:
3) For Visual Studio C++ x64 projects, go to project properties and add the following paths accordingly:
Choose the correct files according to your project build (x64 or x86).
To install gcc
on MSYS2 on Windows:
yes | pacman -Syu gcc
That's it!
By installing gcc
on MSYS2, you automatically get pthreads
as well.
Here is an example that demonstrates pthreads on MSYS2 (& Linux).
In short - the exact same code as on Linux works fine if you compile and run it inside an MSYS2 terminal. (Not necessarily always true, but true for the example in the link.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With