This is the mail archive of the mailing list for the pthreas-win32 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pthreads-win32 and static linking


On Mon, May 10, 2010 at 4:50 PM, Martin Lambers <> wrote:
> The Mingw-cross-env project provides a MinGW cross-compiling environment
> for POSIX systems. For various reasons, all included libraries are
> static, including the pthreads-win32 library.
> This means that all pthreads users need to call
> pthread_win32_thread_attach_np() and pthread_win32_thread_detach_np() in
> each thread function.
> We would like to avoid patching all libraries that use pthread, and
> instead change pthreads-win32: instead of using a thread main function
> given to pthread_create() directly, pthreads-win32 could use an internal
> wrapper that calls the thread main function and also calls the
> attach/detach functions if necessary.
> To avoid the pthread_win32_process_attach() function, pthreads-win32
> could check on each function call whether the library was initialized,
> and if not, call pthread_win32_process_attach() itself.
> This would induce some overhead, but would allow us to use a large
> number of existing libraries unchanged.
> Before we start to work on a patch, we would like to know if this
> approach has a chance to work. Do you know any technical reasons why
> this might fail?

This has been discussed before. Search this list's archive. The
solution I'm currently using is attached (to patch latest CVS). It
removes the false wsock32 dependency, remove the need to define
something before using the static lib (in mingw32) and hints the
linker to automatically initialize the library. The library can be
built/used by both MSVC and GCC.

Ramiro Polla

Attachment: autostatic.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]