I got the following test program:
#include <stdio.h>
#include "pthread.h"
void* test_thread(void *ptr)
{
printf("In teh thread");
return NULL;
}
int main(void)
{
int foo = 1;
pthread_t t;
if (0 != pthread_create(&t, NULL, test_thread, (void *)foo)) {
printf("This was never going to work.");
}
while(1)
;
return 0;
}
When building, I'm getting the following errors:
1>main.obj : error LNK2019: unresolved external symbol _imp_pthread_create referenced in function _main 1>C:\Users\rtt.PROLAN\Downloads\pthread-win32-master\Debug\Majs.exe : fatal error LNK1120: 1 unresolved externals
I built the static library from this source. I then added "pthread_lib.lib" to Linker -> Input in the Project properties. And made sure that file was in the lib path.
Any idea what's causing the linker errors?
gcc
, instead of microsoft's c compiler which is still C89? With that, such basic libraries as pthread already come with the (almost-)POSIX-compliant gnu libraries. – Shahbaz