Undefined reference to pthread_create

后端 未结 5 855
北荒
北荒 2021-01-12 09:06

I have this code:

#include 
#include 

void* cuoco(void* arg)
{
    fprintf(stderr,\"Inizio codice cuoco\\n\");
    fprintf(s         


        
5条回答
  •  不要未来只要你来
    2021-01-12 09:26

    Without seeing the compiler command, I suspect -lpthread is not at end. Libraries need to be placed at end of the compiler command:

    gcc main.c -lpthread

    However, use -pthread instead of -lpthread, as -pthread may add other settings (like defining the macro _REENTRANT for example).

提交回复
热议问题