add -pthread, fix link order