I’ve been working on a multi-platform game engine and I faced same issue only on Linux. If you are using cmake add following to your cmake file:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
If you are not using cmake you need to add this flag for your compiler manually.
The complete cmake for using threads in linux systems must contain following commands:
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
Note: Also this fix works for Mac-Os but with one difference. You don’t need to pass -pthread as compiler flag