Properly link with pthread. Fixes build on some systems.