C++ 多线程编译出现问题
#include <pthread.h>
#include "iostream.h"
void* tprocess1(void* args){
while(1){
cout << "tprocess1" << endl;
}
return NULL;
}
void* tprocess2(void* args){
while(1){
cout << "tprocess2" << endl;
}
return NULL;
}
int main(){
pthread_t t1;
pthread_t t2;
pthread_create(&t1,NULL,tprocess1,NULL);
pthread_create(&t2,NULL,tprocess2,NULL);
pthread_join(t1,NULL);
return 0;
}
错误提示:
Compiling...
2.cpp
Linking...
2.obj : error LNK2001: unresolved external symbol __imp__pthread_join
2.obj : error LNK2001: unresolved external symbol __imp__pthread_create
Debug/多线程.exe : fatal error LNK1120: 2 unresolved externals
执行 link.exe 时出错.
多线程.exe - 1 error(s), 0 warning(s)