Skip to content

GCC Compiler Errors And How To Fix Them

Published On:
Feb 2, 2019
Last Updated:
Feb 2, 2019

undefined reference to `pthread_create’

This error usually occurs when trying to compile C++ code which uses threads on Linux. This error can usually be fixed by adding the option -pthread to the call to g++, e.g.:

Terminal window
$ g++ -pthread main.cpp