hey
im running on linux (fedora) and im tring to run this code :
Code:
#include <pthread.h> /* include file for pthreads - the 1st */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <sys/fcntl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#include </usr/include/signal.h>
void *Thread(void *string)
{
int i;
/* writes five messages and exits */
for (i=0; i<5; i++)
printf("%s\n", (char *)string);
pthread_exit(NULL);
}
int main()
{
char *e_str = "Hello!";
char *f_str = "Bonjour !";
pthread_attr_t attr;
pthread_t e_th;
pthread_t f_th;
int rc;
/* creates the right attribute */
//pthread_attr_init(&attr);
//pthread_attr_setdetachstate(&attr,1);//PTHREAD_CREATE_UNDETACHED
/* creates both threads */
rc = pthread_create(&e_th, NULL, Thread, (void *)e_str);
if (rc)
exit(-1);
rc = pthread_create(&f_th, NULL, Thread, (void *)f_str);
if (rc)
exit(-1);
//pthread_attr_destroy(&attr);
/* joins the threads */
pthread_join(e_th, NULL);
pthread_join(f_th, NULL);
pthread_exit(NULL);
}
and im getting the next error on compilation time:
"undefined reference to `pthread_create' " and "undefined reference to `pthread_join'"
does someone know what is the problem ?
thanks !