Hey Guys,
I've learned programming in C in school for about one yearand a half and now I wanted to try myself in parallel programming. I downloaded the Pthread-files and tried to write a sorting program with and without pthreads to compare how fast they are. But when I try to compile my parallel program I get two errors I don't understand:
"undefined reference to _imp_pthread_create"
"undefined reference to _imp_pthread_join"
I can't find any mistakes in my program, maybe anyone of you can help me. This is my Program:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
void *DieOberen50000 (int a[100000])
{
int i,j,h,m;
for (i=100000;i>=50000;i--)
{
m=i;
for (j=0;j<=i;j++)
{
if (a[j]>a[m])
{
m=j;
}
}
h=a[m];
a[m]=a[i];
a[i]=h;
}
}
void *DieUnteren50000(int a[100000])
{
int i,j,h,m;
for (i=0;i<=50000;i++)
{
m=i;
for (j=i;j<=100000;j++)
{
if (a[j]<a[m])
{
m=j;
}
}
h=a[m];
a[m]=a[i];
a[i]=h;
}
}
void main()
{
int rc,i,a[100000];
void *valuep;
time_t seconds;
pthread_t *Schleife1,*Schleife2;
srand(time(NULL));
for (i=0;i<100000;i++)
{
a[i]=rand() % 10000;
printf("%d ",a[i]);
}
printf("\n\n");
seconds = time (NULL);
rc = pthread_create(Schleife1,NULL,DieOberen50000, a);
rc = pthread_create(Schleife2,NULL,DieUnteren50000,a);
rc = pthread_join (*Schleife1,&valuep);
rc = pthread_join (*Schleife2,&valuep);
for (i=0;i<100000;i++)
{
printf("%d ",a[i]);
}
seconds = time(NULL) - seconds;
printf("\n\n %ld", seconds);
scanf("%d",i);
}
PS: I'm using lcc-win32 on Windows Vista.