Wednesday, August 19, 2009

MinGW: Posix Threads for Win32

Because a good number of software from Linux require Posix threads, porting them to a Win32 platform can be a problem as Windows is not a POSIX-compliant platform. I found an open-source project Pthreads-w32 that specifically deals with this issue. I downloaded pthreads-w32-2-8-0-release.tar.gz from the FTP site and unpacked it. Then, I issued the following command:


make clean GC-static

This produces a static library libpthreadGC2.a. I installed it by manually copying the headers and static library:


cp -iv pthread.h semaphore.h sched.h /mingw/include/
cp -iv libpthreadGC2.a /mingw/lib
cp -iv libpthreadGC2.a /mingw/lib/libpthread.a

When using the static library, don't forget to define PTW32_STATIC_LIB with CPPFLAGS.


CPPFLAGS="-DPTW32_STATIC_LIB"
export CPPFLAGS

I have yet to learn how to use this Posix thingy. I think it probably involves including the headers in my code and linking with the static library libpthread.a at the final linking stage.

No comments:

Post a Comment

About This Blog

KBlog logo This blog seeks to provide a collection of interesting pictures found on the Web. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

Powered By Blogger