I was trying to create threads in my code. This is the first time I tried this I used these as reference
http://www.opengroup.org/onlinepubs/...ad_create.html
and
http://www.mit.edu:8001/people/prove...c_example.html
but I always get a error message saying
engine_driver.o: In function `e_admit_to_engine':/home/shahan/engine_driver.c:39: undefined reference to `pthread_create'
:/home/shahan/engine_driver.c:43: undefined reference to `pthread_detach'
collect2: ld returned 1 exit status
it doesnt recognize the functins
can any one help me on this???
I enterd the code here (only the part I use threads. I return NULL in engine_ex_comm_write )
Code:
#include <pthread.h>
#include "engine.h"
void * engine_ex_comm_read(profile_t *data);
void * engine_ex_comm_write(profile_t *data);
int e_admit_engine();
int e_admit_to_engine()
{
profile_t *this_data;
//extern void * start_routine(void *ths_data);
//char * this_data1;
profile_t *new_profile;
element_t *new_element, *new_element1;
profile_t * loc;
int y=0, x, ret;
pthread_t tid;
pthread_attr_t attr;
while(1)
{
if(y!=is_buffer_emty())
{
this_data= read_from_buffer();
if(this_data)
{
engine_ex_comm_write(this_data);
if( pthread_create(&tid, NULL, engine_ex_comm_write, this_data))
{
printf("error creating thread\n");
}
pthread_detach(tid);
}