Prefer -pthread to -lpthread.
Need -pthread on Linux too.