Search code examples
c++lockingpthreads

pthread mutex: error LNK2019: unresolved external symbol c++


I'm obtaining this link error and I cannot find the solution. Can you maybe put me in the right direction where to search for it? I get: error LNK2019: unresolved external symbol _imp_pthread_mutex_lock referenced in function "private: bool __thiscall... here comes the whole name of my function with parameters. pthread_mutex_lock and pthread_mutex_unlock are used in this function (not as arguments). Including "pthread.h" doesn't change anything.


Solution

  • The pthread library is for POSIX systems (Linux, BSD, Mac OS). You indicated that you're on Visual Studio in Windows - if you are looking to do multithreading on Windows, see this page.

    Better yet, if you can use more recent tools, C++11 offers built-in threading functionality.