I have a small C++ Win32 command line app, built with VS2008 that makes use of pthreads. I want to distribute the app as a standalone executable, so link to pthreads statically: in the Linker -> Input page of the project property, I've added pthreadVC2.lib to the Additional Dependencies. The project builds, but the executable still needs pthreadVC2.dll in order to run, despite my linking statically to the lib file.
Depends.exe indeed lists pthreadVC2.dll as a dependency.
Any idea why this is? Thanks
Tom
If you want to link statically, you need to link to the static library. The pthreadVC2.lib
file is the stub for the DLL, not the static library.
Note that to use the static library, you must follow the rules for static attachment. For example, you must call pthread_win32_process_attach_np. You will need to make the calls into the library (on process attach, thread attach, thread detach, and process detach) that the Windows DLL scheme normally does for you.
Edit: This step may not be necessary according to latest documentation in that link:
As of version 2.9.0, the static library built using either MSC or GCC includes RT hooks which will call the pthread_win32_process_*_np routines automatically on start/exit of the application.