#include <iostream> #include <thread> class A{ public: static thread_local long l ; int value ; A(int a = 2){ value = a; } int foo(){ A::l = 3; return 3; } }; A a; int main(){ // A::l = 3; a.foo(); return 0; } above code on compiling gives error can someone help to resolve them? when i remove the reads and writes to static thread_local this seems to compile . does it needs some special libraries or linkers to work properly . I need to keep static thread_local to get same features as threadLocal class in java