use -pthread instead of -lpthread