Dienstag, 12. Februar 2013

pthreads-w32

What is Pthreads?

Pthreads is the standard API for creating and managing threads on UNIX systems. This API is not natively supported on Windows, but there is a free library called pthreads-w32 which provides the same functionality under Windows. In this way, you can develop a multi-threaded program which will work on both types of systems.

Installation and Quickstart

1. Download library

Web: ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.tar.gz

2. Build library

make clean GC

3. Install libs

mkdir "%userprofile%\lib\pthreads-w32"
cp -v *.dll *.a "%userprofile%\lib\pthreads-w32"

4. Install header files

mkdir "%userprofile%\include\pthreads-w32"
cp -v pthread.h sched.h semaphore.h "%userprofile%\include\pthreads-w32"

5. Update environment

Add static libs dir to LIBRARY_PATH
Add headers dir to CPATH

6. Compile a test program

(Using the test program from
https://computing.llnl.gov/tutorials/pthreads/#CreatingThreads)

gcc -o trythread trythread.c -lpthreadGC2

References

Pthreads Tutorial (not specific to pthreads-w32) - https://computing.llnl.gov/tutorials/pthreads/

Keine Kommentare:

Kommentar veröffentlichen