ich diese Fehler bin immer während ich gehören die pthread
Bibliothek:Warnung beim Kompilieren pthread_join auf meinem Rechner ubuntu 16.0
implicit declaration of function ‘pthread_created’ [-Wimplicit-function-declaration] pthread_created(&id1,0,thread2,NULL);
undefined reference to `pthread_created' collect2: error: ld returned 1 exit status
#include<stdio.h>
#include<pthread.h>
#include<stdlib.h>
void* thread1(void* args)
{
int i = 0;
for (i = 0; i < 100; i++)
{
if (i % 2 == 0)
{
printf("%d\n", i);
}
}
}
void* thread2(void* args)
{
int i = 1;
for (i = 0; i < 100; i++)
{
if (i % 2!= 0)
{
printf("%d\n", i);
}
}
}
int main()
{
pthread_t id, id1;
printf("before thread 1 is created");
pthread_create(&id, 0, &thread1, NULL);
pthread_join(id, 0);
printf("after thread 1 is created\n");
printf("before thread 2 is created");
pthread_created(&id1, 0, thread2, NULL);
pthread_join(id1, 0);
printf("after thread2 is created");
return 0;
}
Dies ist ein Linker-Fehler. Wie verlinken Sie das? – Wodin