pthread static linking with application in visual studio 2013

1.2k views Asked by At

I want to pthread lib statically linked with my application so that at other target without install pthread lib my .exe will run.

For that I have add pthreadVC.lib in Linker->input->additional dependency of visual studio and also given correct path for lib.

Also I add this code #define PTW32_STATIC_LIB in my thread.h file before #include <pthread.h>

My application build successfully and running on same machine. But I trying to run on other target I got error pthreadVC.dll is missing .

Please tell me where I am missing.

1

There are 1 answers

0
Mohan On BEST ANSWER

In my case i was not having static lib and i was trying to do static link with dynamic lib. Following are steps to do static linking .

  1. Download source code of Pthread_Win32 and build it with visual studio.
  2. So now you will have static lib (pthread_lib.lib) probably at path .........\pthread-win32-master\pthread-win32-master\bin\Win32_MSVC2013.Release
  3. In your application go into project properties mainly Linker->input->additional dependency and add pthread_lib.lib.
  4. Also add path of pthread_lib.lib into visual studio properties Linker->General->Additional Library Directories.
  5. Add this code #define PTW32_STATIC_LIB in header file.