PTW Static Linking
12/26/05
Robin.Rowe@MovieEditor.com

How best to handle Pthreads for Windows as a static lib isn't entirely clear. Enclosed below are additional instructions for making it work static. All I've done is define PTW32_STATIC_LIB.

PTW32_STATIC_LIB must be defined in all projects that include pthread.h, otherwise will default to dllimport.

static: PTW32_STATIC_LIB
dll: PTW32_BUILD

Robin



DLL vs. static: READMES need more instructions for static
From: "neal olander" <olanderfamily at hotmail dot com>
To: pthreads-win32 at sources dot redhat dot com
Cc: rpj at callisto dot canberra dot edu dot au
Date: Sat, 21 May 2005 15:24:50 -0700
Subject: DLL vs. static: READMES need more instructions for static

Hey. I've been using pthread on XP for several months now ... great library!!! thanks for all the hard work!

My application must be totally stand-alone, and we cannot deliver DLLs with our executable. So I need a static version of pthreadVC2.lib. Until yesterday, I was using pthreadVC2.dll.

I've got version 2.1.0 (16 March 2005) of Pthread lib.

It seems to me that static versions of pthread library on Windows are discouraged: The Makefile only makes a DLL (and pthreadVC2.lib ... which is just a wrapper for the DLL). Why is a static library avoided?

It took me many, many hours of hard work to get a static pthread.lib built in Visual C++ ... and I'm not 100% sure it is correct. I had to have my application call
int status = pthread_win32_process_attach_np();
at the beginning to get it to work. This took me forever to figure out. This guidance is buried in README.NONPORTABLE, so I cant claim it is totally missing.

May I suggest (in a very positive, helpful tone :-) that you add to the readme:

IF YOU WANT STATIC LINKED LIBRARY
1)  undef _DLL
2) your appl must call  pthread_win32_process_attach_np();
3) In the key pthread header files, put in


#  ifdef PTW32_BUILD
#    define PTW32_DLLPORT extern
#  else
#    define PTW32_DLLPORT
#  endif


in lieu of the PTW32_BUILD stuff that is there now.
4) define PTW32_BUILD when building pthread static lib; undefine when
building your application.

==============================
THanks again for a great library!!!
My comments are simply given to try to help others that come along later that will want a static pthread library.

neal


Neal Olander
olanderfamily@hotmail.com