0

so I'm using visual studio 2019 and I installed pthread package but whenever I run my code the following error pops up "'timespec': 'struct' type redefinition "

the most common solution I found is to put #define HAVE_STRUCT_TIMESPEC before including pthread.h but whenever I do so two errors occur:

1- LNK2019 unresolved external symbol __imp__pthread_create referenced in function _main

2- 1 unroslved externals

I know this problem is common but I didn't find any solution to the two new errors specified.

zamnas
  • 1
  • 1
  • 1
    We cannot reliably debug the issue from the information provided, so the best way forward, whether to discovering the problem for yourself or to getting a diagnosis from us, is to trim it down to a [mre] that demonstrates the issue. – John Bollinger Oct 27 '21 at 12:07
  • 1
    What we can tell you is that you are getting definitions of `struct timespec` from two different sources -- probably, but not necessarily, from two different headers. If one of those is `pthread.h` and the other is from MSVC[++], then the pthreads implementation you have installed is not fully compatible with your implementation, but it's also possible that one of the definitions is in your own code. – John Bollinger Oct 27 '21 at 12:12
  • 1
    The link error is an altogether separate issue. The pthreads package you installed ought to provide at least a few words of documentation for how to include the pthreads library in the MSVC++ link. See https://stackoverflow.com/q/12573816/2402272. – John Bollinger Oct 27 '21 at 12:16

0 Answers0