c - Undefined reference to pthread_create in Linux
I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/

For Linux the correct command is:
gcc -pthread -o term term.c

In general, libraries should follow sources and objects on command line, and -lpthread is not an "option", it's a library specification. On a system with only libpthread.a installed,
gcc -lpthread ...

will fail to link.
Read this or this detailed explanation.
