1. Building the library as a statically linkable library
-----------------------------------------------------
General:ptw32_static_lib must is defined for both the library build and the
Application build. The makefiles supplied and used by the following ' make '
Command lines would define this for you.
MSVC (creates pthreadVCn.lib as a static link lib):
NMAKE Clean vc-static
MINGW32 (creates libpthreadgcn.a as a static link lib):
Make Clean gc-static
Define Ptw32_static_lib when building your application. Also, your
Application must call a and non-portable routines to initialise the
Some state on startup and cleanup before exit. One other routine needs
To is called to cleanup after any Win32 threads has called POSIX API
Routines. See README. Nonportable or the HTML reference manual pages for
Details on these routines:
BOOL pthread_win32_process_attach_np (void);
BOOL pthread_win32_process_detach_np (void);
BOOL pthread_win32_thread_attach_np (void); Currently a No-op
BOOL pthread_win32_thread_detach_np (void);
The tests makefiles has the same targets but only check the
The static library is statically linkable. They don ' t run the full
Testsuite. To run the full testsuite, build the DLLs and run the
DLL test targets.
=============================================
2. Using the Pthread-win32 Static library
Use Pthread-win32 Static library to note:
1) in the program to define the macro Ptw32_static_lib
2) Pthread-win32 Static library does not do attach and detach operations, to the programmer to complete the task,
Otherwise the line threads can be created successfully. Specific as follows:
The following two functions are called at the entrance of the program (usually the main function)
PTHREAD_WIN32_PROCESS_ATTACH_NP ();
PTHREAD_WIN32_THREAD_ATTACH_NP ();
Called at the end of the program
PTHREAD_WIN32_THREAD_DETACH_NP ();
PTHREAD_WIN32_PROCESS_DETACH_NP ();
No way, the Windows system has a lot of standards it does not support, it is necessary to write a little trouble.
This can be done simply by:
A) define the processing function at the end of the program
#ifdef Ptw32_static_lib
void Pthread_win32_detach (void)
{
PTHREAD_WIN32_THREAD_DETACH_NP ();
PTHREAD_WIN32_PROCESS_DETACH_NP ();
}
#endif
b) call at the entrance of the program as follows
#ifdef Ptw32_static_lib
PTHREAD_WIN32_PROCESS_ATTACH_NP ();
PTHREAD_WIN32_THREAD_ATTACH_NP ();
Atexit (Pthread_win32_detach);
#endif
Static compilation pthread under Windows