Help with pthread error

I have written a C code and when i compile it there are 0 warnings and 0 errors, but when i try to run apears:

./client: symbol lookup error: ./client: undefined symbol: pthread_create, version GLIBC_2.1

the part of the code where i have the pthread_creat is:

int serverConection(int socket, int number){
    char buffer;
    int recvd;
    pthread_t thread;
    DATA tdata;

    recvd = receivFile(socket, number);
    if(recvd != 0) return -1;
    if(send(socket,&number,sizeof(int),0) <= 0)return -1;
    
    while(recv(socket,buffer,SIZE,0)){
        buffer[strlen(buffer)-1] = '\0';
        
        if(strcmp(buffer,"STARTPLAY")){
                    tdata->wait = 0;
                    tdata->period = 45454;
                    tdata->number = number;
                    //pthread_create(&thread,NULL,clientConnect,(void *)auxSocket);    
                    pthread_create(&thread,NULL,showBanner,&tdata);
        }        
    }
    return 0;
}

i don't understand what's happening i have already used this function many times and this is the first time this happened, i really need some help.
thx

Are you running on the same physical machine where it was compiled?

You would get that error if for example you compiled without -lpthread. My thought is that it really did not (re)compile correctly. make will not recompile something if it thinks the executable is "current"
Please post the output of of

ldd ./client

Sorry i didnt post this earlier, but i know why i had that error, it wasnt any compiler error, it was beacuse the way i had that i was creating that thread over and over again in an infinit loop. a litle error in my code but al fixed now. thx anyway.:slight_smile:

Minor correction. The program wouldn't compile, and the linker would issue an error like:

undefined reference to `pthread_create'

Here the problem occurs at runtime. Your thought seems correct.

You may need indeed to fix this additional error. However, it is rather unlikely to have something in common with the problem you have initially reported. Jim's likely right; a clean recompile may have resolved your "undefined symbol" problem.

Cheers, Lo�c

I think binary wont have got created if "-lpthread" is not used for compiling.

I had compiled with -lpthread, if i didn't the compiler would give me an error.
the problem was what i had said in the previous response.
thx for the help but is now fixed:D