问题
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'.
回答1:
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.
回答2:
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:
- "Pre-built.2\dll\x64\pthreadVC2.dll" OR "Pre-built.2\dll\x86\pthreadVC2.dll"
- "Pre-built.2\lib\x64\pthreadVC2.lib" OR "Pre-built.2\lib\x86\pthreadVC2.lib"
- "Pre-built.2\include\pthread.h"
- "Pre-built.2\include\sched.h"
- "Pre-built.2\include\semaphore.h"
3) For Visual Studio C++ x64 projects, go to project properties and add the following paths accordingly:
- Additional lib Files add "yourpath\Pre-built.2\lib\x64\"
- Additional dll files add "yourpath\Pre-built.2\dll\x64\"
- Additional include files add "yourpath\Pre-built.2\include\"
Choose the correct files according to your project build (x64 or x86).
来源:https://stackoverflow.com/questions/19467455/how-to-set-up-pthreads-on-windows