https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77285
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Without the header: cat > a.cpp <<EOF #include <string> thread_local std::string gFeelingLucky; EOF cat > main.cpp <<EOF #include <string> extern thread_local std::string gFeelingLucky; int main() { return gFeelingLucky.length(); } EOF g++11 main.cpp a.cpp -o main /tmp/ccpboHS6.o: In function `TLS wrapper function for gFeelingLucky': main.cpp:(.text._ZTW13gFeelingLucky[_ZTW13gFeelingLucky]+0x5): undefined reference to `TLS init function for gFeelingLucky' collect2: error: ld returned 1 exit status