For me the best answer was the comment from pts if only he bothered to submit it as answer:
You investigated properly and answered
your own question. Useg++ -pthread,
it is equivalent tog++ -lpthread -D_REENTRANT.
Usingg++ -D_REENTRANTwould be different,
it may not set all the linker flags. –
pts May 18 at 0:30