OpenWrt Forum Archive

Topic: using pthreads in openwtr code

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hi, I need to use a thread in an own package I'm doing.

I've got something like that

#include<pthread.h>

void *hahaha(void *vargp)
{
        printf("hohoho\n");
    return NULL;
}

int main(int argc,char **argv)
{ 
    pthread_t tid;
    pthread_create(&tid, NULL, hahaha, NULL);
    pthread_join(tid, NULL);
        return 0;
}

I also put the flag -pthread in the makefile and it compiles successfully, b

my_package: $(OBJDIR)my_package.o $(OBJDIR)list.o
    $(CXX) $(OBJDIR)my_package.o -lpthread $(OBJDIR)list.o -o $@ $(LDFLAGS) -lpcap

ut when executing it, the next error appears:

can't load library 'libpthread.so.0' 

any idea?

Install libpthread?

The discussion might have continued from here.