Try also linking without -pthread and do not use it when not needed (clang on OS X)