My env is Windows8.1 (64bit) and using Visual Studio 2010.
I did put all *.dll files in system32 , SYSWOW64(because I use win8 64bit.)
and link location where *.lib file for x64-system with VC 2010.
of course, I add additional folder lib forders.. , include folders.. etc..
but when I try compile "pthread-used" project, fatal error has occur.
-source
#include<pthread.h>
#include<stdio.h>
int doit_id,trd_id;
pthread_t trd;
void *doit(void *data){
doit_id = (int)data;
return 0;
}
int main(){
trd_id=pthread_create(&trd,NULL,doit,0);
return (0);
}
-error
1.obj : error LNK2019: unresolved external symbol __imp__pthread_create (referenced in function _main)
C:\Users\~program Location~ : fatal error LNK1120: 1 unresolved externals
please,help me
The fact that your main()
is looking for the name __imp__pthread_create
indicates that you're building your project for a 32-bit target.
The 64-bit Win32 pthread library has a import symbol for pthread_create()
with the name:
__imp_pthread_create
The 32-bit Win32 pthread libary has:
__imp__pthread_create
Note the extra underscore in the 32-bit lib - that matches the name convention that your main()
is looking for, so it's an indication that you're building for a 32-bit target. The extra underscore is part of how x86 builds treat names in the cdecl calling convention used by the Win32 pthread library. x64 doesn't use a cdecl calling convention (x64 has only a single calling convention) and underscores are not prepended to symbols in x64 builds.
I think you need to either download or build the 32-bit pthread library or change your project configuration to build for a 64-bit target.