A: 

Do not use -lpthread. This merely links with the library which provides the thread handling functions. Full threading support may require more than that, e.g. linking with a specially thread-safe version of libstdc++, or reserving a specific register for thread-local variable access.

With gcc or g++, use the -pthread command-line flag, both for compilation and for linking. This will instruct gcc to do whatever is necessary to enable reliable threading, including, but not limited to, adding the -lpthread flag when required.

Thomas Pornin