Wednesday, July 6, 2011

POSIX Thread and MS Visual Studio 2008


For the application of POSIX Thread to Windows (MS Visual Studio), POSIX Thread for Win32 is required. By efforts of Ben Elliston et al, the source tree and precompiled .DLL, .LIB and necessary header files are included in the self-extracting zip file named "pthread-w32-v-v-v-release.exe" at: ftp://sourceware.org/pub/pthreads-win32 (unless visit http://sourceware.org/pthreads-win32/)

After extraction,
1) Copy those files as follows (in my case):
- *.dll: C:\PThread2.8\bin
- *.h (three files): C:\PThread2.8\include
- *.lib & *.a: C:\PThread2.8\lib


2) Set MS Visual Studio Options as follows:
- Tools->Options->Project and Solutions->VC++ Directories
--> Add C:\PThread2.8\bin in Executable files
--> Add C:\PThread2.8\include in Include files
--> Add C:\PThread2.8\lib in Library files

3) Add a library file MS Visual Studio Project Property
- Project Property -> Configuration Properties -> Linker->Additional Dependencies
- 'pthreadVC2.lib' is recommended for MS Visual Studio


* Note
For examples given by the Internet, thread functions needs to add a line "return NULL;".
(It may be a problem for win32 application only.)

No comments:

Post a Comment