我无法在窗口平台中使用pthread

KOR*_*RCJ 2 c pthreads pthreads-win32

我的env是Windows8.1(64位)并使用Visual Studio 2010.

我确实将所有*.dll文件放在system32,SYSWOW64中(因为我使用win8 64bit.)

并使用VC 2010链接x64-system的*.lib文件的位置.

当然,我添加了额外的文件夹lib forders ..,包括文件夹..等..

但是当我尝试编译"pthread-used"项目时,会发生致命错误.

-资源

#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);
}
Run Code Online (Sandbox Code Playgroud)

-错误

1.obj : error LNK2019: unresolved external symbol __imp__pthread_create (referenced in function _main)
C:\Users\~program Location~ : fatal error LNK1120: 1 unresolved externals
Run Code Online (Sandbox Code Playgroud)

请帮我

Mic*_*urr 6

main()正在寻找名称的事实__imp__pthread_create表明您正在为32位目标构建项目.

64位Win32 pthread库具有名称的导入符号pthread_create():

__imp_pthread_create
Run Code Online (Sandbox Code Playgroud)

32位Win32 pthread库包含:

__imp__pthread_create
Run Code Online (Sandbox Code Playgroud)

请注意32位lib中的额外下划线 - 与您main()正在寻找的名称约定相匹配,因此它表明您正在为32位目标构建.额外的下划线是x86如何在Win32 pthread库使用的cdecl调用约定中处理名称的一部分.x64不使用cdecl调用约定(x64只有一个调用约定),并且下划线不会添加到x64构建中的符号之前.

我认为您需要下载或构建32位pthread库或更改项目配置以构建64位目标.