I picked up the following demo off the web from https://computing.llnl.gov/tutorials/pthreads/
#include
#include
#define NU
For Linux the correct command is:
gcc -o term term.c -lpthread
If you are using cmake, you can use:
add_compile_options(-pthread)
Or
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
in eclipse
properties->c/c++Build->setting->GCC C++ linker->libraries in top part add "pthread"
you need only Add "pthread" in proprieties=>C/C++ build=>GCC C++ Linker=>Libraries=> top part "Libraries(-l)". thats it
In Visual Studio 2019 specify -pthread
in the property pages for the project under:
Linker -> Command Line -> Additional Options
Type in -pthread
in the textbox.
Sometimes, if you use multiple library, check the library dependency. (e.g. -lpthread -lSDL... <==> ... -lSDL -lpthread)