Link with -pthread instead of -lpthread