我正在使用C上课,但我不太擅长,所以我想问你,我该如何解决这个问题:“ Id返回1退出状态”,我一直在努力在相当长的一段时间内,因此我非常感谢您的帮助。
#include <iostream>
#include <pthread.h>
using namespace std;
void * fun_thread1(void *data)
{
for(int i=0;i<100;i++)
{
cout<<endl<<"In Thread 1"<<endl;
}
}
void * fun_thread2(void *data)
{
for(int i=0;i<100;i++)
{
cout<<endl<<"In Thread 2"<<endl;
}
}
int main(int argc, char *argv[])
{
int status;
// creating thread objects
pthread_t thrd_1;
pthread_t thrd_2;
// create thread
pthread_create(&thrd_1,NULL,fun_thread1,(void *)0);
pthread_create(&thrd_2,NULL,fun_thread2,(void *)0);
pthread_join(thrd_1, (void **)&status);
pthread_join(thrd_2, (void **)&status);
system("PAUSE");
return EXIT_SUCCESS;
}
错误:
C:\Users\Zeeshan Pasha\Documents\Untitled3.o Untitled3.cpp:(.text+0x1cd): undefined reference to `__imp_pthread_join'
C:\Users\Zeeshan Pasha\Documents\Untitled3.o Untitled3.cpp:(.text+0x1f1): undefined reference to `__imp_pthread_join'
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe Untitled3.o: bad reloc address 0x0 in section `.pdata'
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe final link failed: Invalid operation
C:\Users\Zeeshan Pasha\Documents\collect2.exe [Error] ld returned 1 exit status