Add -pthread to LDFLAGS too.