Undefined reference to pthread_create in Linux

后端 未结 14 2654
梦毁少年i
梦毁少年i 2020-11-22 03:18

I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/

#include 
#include 
#define NU         


        
14条回答
  •  感动是毒
    2020-11-22 04:01

    For Linux the correct command is:

    gcc -o term term.c -lpthread
    
    1. you have to put -lpthread just after the compile command,this command will tell to the compiler to execute program with pthread.h library.
    2. gcc -l links with a library file.Link -l with library name without the lib prefix.

提交回复
热议问题